aboutsummaryrefslogtreecommitdiffstats
path: root/csc/hash-map.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-07-26 21:00:43 -0700
committerRose Hogenson <rhogenson@posteo.net>2022-07-26 21:00:43 -0700
commit5994a8fec4525010a9a4d97c806070c0be4c99d6 (patch)
tree8cfd685797e32e6c930d666e767ceebef4cc02c1 /csc/hash-map.csc
parentFix a potential R7RS issue. (diff)
downloadchromatopelma-5994a8fec4525010a9a4d97c806070c0be4c99d6.tar.zst
Slightly improve the hash function.
Diffstat (limited to 'csc/hash-map.csc')
-rw-r--r--csc/hash-map.csc13
1 files changed, 7 insertions, 6 deletions
diff --git a/csc/hash-map.csc b/csc/hash-map.csc
index 064b4ae..682fa30 100644
--- a/csc/hash-map.csc
+++ b/csc/hash-map.csc
@@ -217,7 +217,7 @@
(define (shuffle n)
- (truncate-remainder
+ (remainder
(* #x9e3779b97f4a7c55 n)
#x10000000000000000))
@@ -291,11 +291,12 @@
(define (hash-bytevector b)
- (let loop ((i 0)
- (hash 0))
- (if (>= i (bytevector-length b))
- hash
- (loop (+ 1 i) (+ (* hash #x100) (bytevector-u8-ref b i))))))
+ (loop for i from 0 below (bytevector-length b)
+ with hash = 0
+ do (set! hash (remainder
+ (+ (* hash #x100) (bytevector-u8-ref b i))
+ #x10000000000000000))
+ finally (return hash)))
(define compare-symbols