hash function for mac needed

Henry Spencer henry at zoo.toronto.edu
Tue Jun 25 15:21:33 AEST 1991


In article <3634 at litchi.bbn.com> rsalz at bbn.com (Rich Salz) writes:
>|In fact, when I originally did the hashed newsgroup-lookup code in C News
>|expire, a quick investigation did not reveal any hashing function which
>|had overall performance much better than simply using the length of the
>|string! ...
>
>I think you'll want to re-check.  The distributions are real uneven -- there
>are more than 40 newsgroups of length 10, for example, so you have to resolve
>lots of conflicts, and if you don't put a secondary hash, that means lots of
>strcmp's...

Strcmps cost much less if you prefix them with an inline check of the
first character.  This strategy isn't as effective with newsgroups (which
tend to have common prefixes) as with random strings, but it still helps
quite a bit.  And *as I mentioned*, the above-mentioned results are out
of date; the hash chains were typically 2-3 long back then.
-- 
"We're thinking about upgrading from    | Henry Spencer @ U of Toronto Zoology
SunOS 4.1.1 to SunOS 3.5."              |  henry at zoo.toronto.edu  utzoo!henry



More information about the Comp.lang.c mailing list