better? hash, sdbm
This commit is contained in:
parent
7bf4c9e577
commit
5e8ab6e3e6
|
@ -36,16 +36,13 @@ static unsigned long hash_addr(void *p)
|
||||||
{
|
{
|
||||||
return (long)p;
|
return (long)p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long hash_string(const char *str)
|
static unsigned long hash_string(const char *str)
|
||||||
{
|
{
|
||||||
unsigned long hash = 0;
|
unsigned long hash = 0;
|
||||||
int i;
|
int c;
|
||||||
int len = strlen(str);
|
while ((c = *str++))
|
||||||
for (i = 0; i < len; i++) {
|
hash = c + (hash << 6) + (hash << 16) - hash;
|
||||||
hash = (hash << 7) | (hash >> (sizeof(hash)*8 - 7));
|
|
||||||
hash ^= str[i]; /* GOLDEN_RATIO_PRIME_32; */
|
|
||||||
}
|
|
||||||
// fprintf(stderr, "%d\n", hash % HASH_SIZE);
|
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue