diff options
author | bjj <bjj> | 2002-08-18 08:51:50 +0000 |
---|---|---|
committer | bjj <bjj> | 2002-08-18 08:51:50 +0000 |
commit | 08859785b511e4c6f6197590e051ad399d830ae4 (patch) | |
tree | 8f01feedab5ae735c668431ed238987f6c2547e4 | |
parent | a029671d4f49a1a9af8264a7c842ee2004ede25d (diff) | |
download | moo-08859785b511e4c6f6197590e051ad399d830ae4.tar.gz moo-08859785b511e4c6f6197590e051ad399d830ae4.tar.xz moo-08859785b511e4c6f6197590e051ad399d830ae4.zip |
Faster and better (?) hash function. Yes it really was slow.
-rw-r--r-- | utils.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -127,13 +127,10 @@ verbcasecmp(const char *verb, const char *word) unsigned str_hash(const char *s) { - unsigned ans = 0; - int i, len = strlen(s), offset = 0; + register unsigned ans = 0; - for (i = 0; i < len; i++) { - ans = ans ^ (cmap[(unsigned char) s[i]] << offset++); - if (offset == 25) - offset = 0; + while (*s) { + ans = (ans << 3) + (ans >> 28) + cmap[(unsigned char) *s++]; } return ans; } @@ -446,6 +443,9 @@ char rcsid_utils[] = "$Id$"; /* * $Log$ + * Revision 1.6 2002/08/18 08:51:50 bjj + * Faster and better (?) hash function. Yes it really was slow. + * * Revision 1.5 1999/08/09 02:36:33 nop * Shortcut various equality tests if we have pointer equality. * |