From: Chris Hanson Date: Fri, 16 Jun 1989 11:32:03 +0000 (+0000) Subject: Change the string hashing algorithm one more time. This one looks X-Git-Tag: 20090517-FFI~12000 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=7df82a67da4e19915b49b8e5989ffe97cfa8ad01;p=mit-scheme.git Change the string hashing algorithm one more time. This one looks like more of a winner than the previous one. --- diff --git a/v7/src/microcode/intern.c b/v7/src/microcode/intern.c index 32a034587..669e0a561 100644 --- a/v7/src/microcode/intern.c +++ b/v7/src/microcode/intern.c @@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ -/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/intern.c,v 9.47 1989/06/16 11:15:04 cph Exp $ */ +/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/intern.c,v 9.48 1989/06/16 11:32:03 cph Exp $ */ /* String hash functions and interning of symbols. */ @@ -41,19 +41,26 @@ MIT in each case. */ /* Hashing strings */ -static long +#define STRING_HASH_BITS 16 + +static unsigned int string_hash (string) Pointer string; { fast unsigned char * scan; fast unsigned char * end; - fast long result; + fast unsigned int result; scan = ((unsigned char *) (string_pointer (string, 0))); end = (scan + (string_length (string))); result = 0; while (scan < end) - result = ((((result & 0x1fff) << 1) | (result >> 13)) ^ (*scan++)); + { + result <<= 1; + result |= (result >> STRING_HASH_BITS); + result ^= (*scan++); + result &= ((1 << STRING_HASH_BITS) - 1); + } return (result); }