summaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2024-07-04 18:48:36 -0700
committerKaz Kylheku <kaz@kylheku.com>2024-07-04 18:48:36 -0700
commit2414f36adfae87c548d8b05e474c5ccda6df5fd6 (patch)
tree1f37fe6d330425a66f1dd00a15c25f7820628463 /hash.c
parent9aa751c8a4f845ef2d2bba091c81ffeded941afd (diff)
downloadtxr-2414f36adfae87c548d8b05e474c5ccda6df5fd6.tar.gz
txr-2414f36adfae87c548d8b05e474c5ccda6df5fd6.tar.bz2
txr-2414f36adfae87c548d8b05e474c5ccda6df5fd6.zip
hash: fix: equal hashes being reduced modulo NUM_MAX.
Almost exactly 6 years ago, commit 612f4f57e 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.
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/hash.c b/hash.c
index 58732193..43763983 100644
--- a/hash.c
+++ b/hash.c
@@ -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;
}