From: Chris Hanson Date: Sat, 26 Sep 2009 05:22:33 +0000 (-0700) Subject: Fix definition of FNV hash. Thanks Taylor! X-Git-Tag: 20100708-Gtk~314 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=42f3c3ee32b83cae7933cb4b99b60ff03ff3ba79;p=mit-scheme.git Fix definition of FNV hash. Thanks Taylor! --- diff --git a/src/microcode/intern.c b/src/microcode/intern.c index fe8461766..9d44262d5 100644 --- 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 }