version 1.37 | | version 1.38 |
---|
| | |
/* | | /* |
* static char *rcsid_arch_c = | | * static char *rcsid_arch_c = |
* "$Id: arch.c,v 1.37 2006/02/10 23:59:25 akirschbaum Exp $"; | | * "$Id: arch.c,v 1.38 2006/03/16 21:54:36 akirschbaum Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
hasharch(const char *str, int tablesize) { | | hasharch(const char *str, int tablesize) { |
unsigned long hash = 0; | | unsigned long hash = 0; |
int i = 0; | | int i = 0; |
unsigned rot = 0; | | const unsigned char *p; |
const char *p; | | |
| | |
| | /* use the one-at-a-time hash function, which supposedly is |
| | * better than the djb2-like one used by perl5.005, but |
| | * certainly is better then the bug used here before. |
| | * see http://burtleburtle.net/bob/hash/doobs.html |
| | */ |
for (p = str; i < MAXSTRING && *p; p++, i++) { | | for (p = str; i < MAXSTRING && *p; p++, i++) { |
hash ^= (unsigned long) *p << rot; | | hash += *p; |
rot += 2; | | hash += hash << 10; |
if (rot >= (sizeof(long) - sizeof(char)) * 8) | | hash ^= hash >> 6; |
rot = 0; | | } |
} | | hash += hash << 3; |
return (hash % tablesize); | | hash ^= hash >> 11; |
| | hash += hash << 15; |
| | return hash % tablesize; |
} | | } |
| | |
/* | | /* |