summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbjj <bjj>2002-08-18 08:51:50 (GMT)
committerbjj <bjj>2002-08-18 08:51:50 (GMT)
commit08859785b511e4c6f6197590e051ad399d830ae4 (patch)
tree8f01feedab5ae735c668431ed238987f6c2547e4
parenta029671d4f49a1a9af8264a7c842ee2004ede25d (diff)
downloadmoo-cvs-08859785b511e4c6f6197590e051ad399d830ae4.zip
moo-cvs-08859785b511e4c6f6197590e051ad399d830ae4.tar.gz
moo-cvs-08859785b511e4c6f6197590e051ad399d830ae4.tar.bz2
moo-cvs-08859785b511e4c6f6197590e051ad399d830ae4.tar.xz
Faster and better (?) hash function. Yes it really was slow.
-rw-r--r--utils.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/utils.c b/utils.c
index a90be44..46ab6a9 100644
--- a/utils.c
+++ b/utils.c
@@ -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.
*