summaryrefslogtreecommitdiffstats
path: root/lib.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-07-06 06:50:18 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-07-06 06:50:18 -0700
commit612f4f57ebb4de7399025acf661837456bc43111 (patch)
tree2fb683147f3a879a551a8511107acf956d01fb13 /lib.h
parent6bbeecf1542da6ca49d15e2816a3c8969b02aa1a (diff)
downloadtxr-612f4f57ebb4de7399025acf661837456bc43111.tar.gz
txr-612f4f57ebb4de7399025acf661837456bc43111.tar.bz2
txr-612f4f57ebb4de7399025acf661837456bc43111.zip
hash: use full width unsigned type for hash values.
Throughout the hashing framework, hashes are reduced into the fixnum range, and returned as cnum. This is not necessary; only the hash-eql and hash-equal functions need to reduce hashes to fixnums. Let's make it ucnum everywhere else, using its full range (no reduction into the [0, NUM_MAX) range). * hash.c (struct hash_ops): hash_fun function pointer returns ucnum instead of cnum. (hash_double): Return unreduced ucnum. Obsolete #ifdef-s removed; the ucnum type gives us a pointer-wide unsigned integer on all platforms. (equal_hash, eql_hash): Return ucnum. Don't reduce values to fixnum range. Some of the way we combine hashes from recursive calls changes; we multiply by at most 2 not to lose too many bits. (eql_hash_op, cobj_eq_hash_op, hash_hash_op): Return ucnum. * hash.h (equal_hash): Declaration updated. * lib.c (cobj_handle_hash_op): Return value changes to ucnum. * lib.h (struct cobj_ops): Hash function pointer's return type changes. (cobj_eq_hash_op, cobj_handle_hash_op): Declarations updated. * struct.c (struct_inst_hash): Return value changes to ucnum.
Diffstat (limited to 'lib.h')
-rw-r--r--lib.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib.h b/lib.h
index 384812d2..718e2c86 100644
--- a/lib.h
+++ b/lib.h
@@ -244,7 +244,7 @@ struct cobj_ops {
void (*print)(val self, val stream, val pretty, struct strm_ctx *);
void (*destroy)(val self);
void (*mark)(val self);
- cnum (*hash)(val self, int *count, ucnum seed);
+ ucnum (*hash)(val self, int *count, ucnum seed);
val (*equalsub)(val self);
};
@@ -265,8 +265,8 @@ val cobj_equal_handle_op(val left, val right);
void cobj_destroy_stub_op(val);
void cobj_destroy_free_op(val);
void cobj_mark_op(val);
-cnum cobj_eq_hash_op(val, int *, ucnum);
-cnum cobj_handle_hash_op(val, int *, ucnum);
+ucnum cobj_eq_hash_op(val, int *, ucnum);
+ucnum cobj_handle_hash_op(val, int *, ucnum);
struct env {
obj_common;