dx_hack_hash stolen from Daniel Phillips <phillips@innominate.de> in the lkml.

This might or might not give hash tables a better spread. We'll see :)
This commit is contained in:
Bill Currie 2001-03-05 16:19:10 +00:00
parent 4c3676b9ac
commit c4616346a1

View file

@ -43,6 +43,8 @@
static unsigned long
hash (const char *str)
{
//FIXME not 64 bit clean
#if 0
unsigned long h = 0;
while (*str) {
h = (h << 4) + (unsigned char)*str++;
@ -50,6 +52,20 @@ hash (const char *str)
h = (h ^ (h >> 24)) & 0xfffffff;
}
return h;
#else
// dx_hack_hash
// shamelessly stolen from Daniel Phillips <phillips@innominate.de>
// from his post to lkml
unsigned long hash0 = 0x12a3fe2d, hash1 = 0x37abe8f9;
while (*str)
{
unsigned long hash = hash1 + (hash0 ^ (*str++ * 71523));
if (hash < 0) hash -= 0x7fffffff;
hash1 = hash0;
hash0 = hash;
}
return hash0;
#endif
}
hashtab_t *