mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-13 00:24:12 +00:00
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:
parent
4c3676b9ac
commit
c4616346a1
1 changed files with 16 additions and 0 deletions
|
@ -43,6 +43,8 @@
|
||||||
static unsigned long
|
static unsigned long
|
||||||
hash (const char *str)
|
hash (const char *str)
|
||||||
{
|
{
|
||||||
|
//FIXME not 64 bit clean
|
||||||
|
#if 0
|
||||||
unsigned long h = 0;
|
unsigned long h = 0;
|
||||||
while (*str) {
|
while (*str) {
|
||||||
h = (h << 4) + (unsigned char)*str++;
|
h = (h << 4) + (unsigned char)*str++;
|
||||||
|
@ -50,6 +52,20 @@ hash (const char *str)
|
||||||
h = (h ^ (h >> 24)) & 0xfffffff;
|
h = (h ^ (h >> 24)) & 0xfffffff;
|
||||||
}
|
}
|
||||||
return h;
|
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 *
|
hashtab_t *
|
||||||
|
|
Loading…
Reference in a new issue