projects
/
mit-scheme.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9aa2665
)
Fix definition of FNV hash. Thanks Taylor!
author
Chris Hanson
<org/chris-hanson/cph>
Sat, 26 Sep 2009 05:22:33 +0000
(22:22 -0700)
committer
Chris Hanson
<org/chris-hanson/cph>
Sat, 26 Sep 2009 05:22:33 +0000
(22:22 -0700)
src/microcode/intern.c
patch
|
blob
|
history
diff --git
a/src/microcode/intern.c
b/src/microcode/intern.c
index fe8461766e7006261aa8ed6344262a83aad6ede3..9d44262d5e716638dd958324e8ff9fed4f018aaf 100644
(file)
--- a/
src/microcode/intern.c
+++ b/
src/microcode/intern.c
@@
-38,11
+38,12
@@
string_hash (uint32_t length, const char * string)
const unsigned char * end = (scan + length);
uint32_t result = 2166136261U;
while (scan < end)
- result = ((result * 16777619U)
+ (*scan++
));
-#if (
BIGGEST_FIXNUM >= 0xFFFFFFFF
)
+ result = ((result * 16777619U)
^ ((uint32_t) (*scan++)
));
+#if (
FIXNUM_LENGTH >= 32
)
return (result);
#else
- return (result & ((uint32_t) BIGGEST_FIXNUM));
+ /* Shorten the result using xor-folding. */
+ return ((result >> FIXNUM_LENGTH) ^ (result & FIXNUM_MASK));
#endif
}