diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2024-07-04 18:48:36 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2024-07-04 18:48:36 -0700 |
commit | 31f6d533938789feaa8ad1a9147eab4698237bc5 (patch) | |
tree | 1f37fe6d330425a66f1dd00a15c25f7820628463 | |
parent | e7ce1b7d7da3fdebee6d5ba67f359bc6e3bb9e52 (diff) | |
download | txr-31f6d533938789feaa8ad1a9147eab4698237bc5.tar.gz txr-31f6d533938789feaa8ad1a9147eab4698237bc5.tar.bz2 txr-31f6d533938789feaa8ad1a9147eab4698237bc5.zip |
hash: fix: equal hashes being reduced modulo NUM_MAX.
Almost exactly 6 years ago, commit 855fbd81c made hashes
use the full width of the ucnum type. However, several
reductions of the form hash &= NUM_MAX were forgotten.
* hash.c (hash_hash_op): Eliminate reductions modulo NUM_MAX.
* struct.c (struct_inst_hash): Likewise.
-rw-r--r-- | hash.c | 5 | ||||
-rw-r--r-- | struct.c | 1 |
2 files changed, 1 insertions, 5 deletions
@@ -775,14 +775,11 @@ static ucnum hash_hash_op(val obj, int *count, ucnum seed) } out += equal_hash(h->userdata, count, seed); - out &= NUM_MAX; us_hash_iter_init(&hi, obj); - while ((*count)-- > 0 && (cell = hash_iter_next(&hi)) != nil) { + while ((*count)-- > 0 && (cell = hash_iter_next(&hi)) != nil) out += equal_hash(cell, count, seed); - out &= NUM_MAX; - } return out; } @@ -1870,7 +1870,6 @@ static ucnum struct_inst_hash(val obj, int *count, ucnum seed) for (sl = 0; sl < nslots; sl++) { ucnum hash = equal_hash(si->slot[sl], count, seed); out += hash; - out &= NUM_MAX; } return out; |