Path: utzoo!attcan!uunet!decwrl!megatest!djones From: djones@megatest.UUCP (Dave Jones) Newsgroups: comp.lang.c Subject: Re: general hash functions for text: SUMMARY! Message-ID: <14308@goofy.megatest.UUCP> Date: 25 Oct 90 03:41:07 GMT References: <1990Oct19.040234.20794@watmath.waterloo.edu> Organization: Megatest Corporation, San Jose, Ca Lines: 20 I just now popped in to comp.lang.c for a peek. See that string-hashing is the hot topic. For years I've been using the following hash-function for tables whose sizes are a power of two. (Dividing by primes is *slowwww*. Never did understand what it gains.) This is the best I could come up with for mc68000's. I don't expect that SPARCification will cause me to change it. int String_hash(str) register char *str; { register int retval = 0; while(*str) retval += retval + (unsigned char)(*str++); return retval; } I've got an original scheme for rehashing that I just love to show off. Later maybe.