summaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1998-12-12 06:58:18 +0000
committerThomas Roessler <roessler@does-not-exist.org>1998-12-12 06:58:18 +0000
commit4833ff046620d1095a92bba22b8a54e0c35f3793 (patch)
tree083a247d7395c677f97a1d6771febc8bd6b5670b /hash.c
parent1c8fc8ceb2c525259173ba6dfd1a6441ed797c5c (diff)
Use a better hash function. Contributed by Stefan Langerman
<lfalse@paul.rutgers.edu> to mutt-users.
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/hash.c b/hash.c
index f7724eb1..3cc0ed5a 100644
--- a/hash.c
+++ b/hash.c
@@ -23,11 +23,22 @@ static const char rcsid[]="$Id$";
#include "mutt.h"
+#define SOMEPRIME 149711
+
int hash_string (const unsigned char *s, int n)
{
int h = 0;
+
+#if 0
while (*s)
h += *s++;
+#else
+ while (*s)
+ h += (h << 7) + *s++;
+ h = (h * SOMEPRIME) % n;
+ h = (h >= 0) ? h : h + n;
+#endif
+
return (h % n);
}