From: Martin Mares Date: Thu, 13 Jul 2000 20:17:30 +0000 (+0000) Subject: Replaced the hash function. Damn it! X-Git-Tag: holmes-import~1632 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=82fc0ac76f9a2fe4f770885604af0a230444a15f;p=libucw.git Replaced the hash function. Damn it! --- diff --git a/lib/db.c b/lib/db.c index 6276e40b..8ccd3533 100644 --- a/lib/db.c +++ b/lib/db.c @@ -146,16 +146,13 @@ static u32 sdbm_hash(byte *key, uns keylen) { /* - * This is the same hash function as GDBM uses. - * It seems to work well. + * This used to be the same hash function as GDBM uses, + * but it turned out that it tends to give the same results + * on similar keys. Damn it. */ - u32 value; - uns index; - - /* Set the initial value from key. */ - value = 0x238F13AF * keylen; - for (index = 0; index < keylen; index++) - value = value + (key[index] << (index*5 % 24)); + u32 value = 0x238F13AF * keylen; + while (keylen--) + value = 37*value + *key++; return (1103515243 * value + 12345); }