diff options
| author | Rose Hogenson <rhogenson@posteo.net> | 2022-07-26 21:00:43 -0700 |
|---|---|---|
| committer | Rose Hogenson <rhogenson@posteo.net> | 2022-07-26 21:00:43 -0700 |
| commit | 5994a8fec4525010a9a4d97c806070c0be4c99d6 (patch) | |
| tree | 8cfd685797e32e6c930d666e767ceebef4cc02c1 | |
| parent | becfaeb778a3c8ba241e2155b998d6b27dcfad0c (diff) | |
| download | chromatopelma-5994a8fec4525010a9a4d97c806070c0be4c99d6.tar.zst | |
Slightly improve the hash function.
| -rw-r--r-- | csc/hash-map.csc | 13 |
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 |
