From 42f3c3ee32b83cae7933cb4b99b60ff03ff3ba79 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Fri, 25 Sep 2009 22:22:33 -0700 Subject: [PATCH] Fix definition of FNV hash. Thanks Taylor! --- src/microcode/intern.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 } -- 2.25.1