diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-02-28 18:45:09 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-02-28 18:45:09 +0800 |
commit | a83b090df287faab2600783fb9cb0b9a081c8d4a (patch) | |
tree | 19803d9e8ae8757ac10b11f871162e6dc689454d /util | |
parent | 0ade3f3a45b99861d3177be9875d215f4ee1a693 (diff) | |
download | pttbbs-a83b090df287faab2600783fb9cb0b9a081c8d4a.tar pttbbs-a83b090df287faab2600783fb9cb0b9a081c8d4a.tar.gz pttbbs-a83b090df287faab2600783fb9cb0b9a081c8d4a.tar.bz2 pttbbs-a83b090df287faab2600783fb9cb0b9a081c8d4a.tar.lz pttbbs-a83b090df287faab2600783fb9cb0b9a081c8d4a.tar.xz pttbbs-a83b090df287faab2600783fb9cb0b9a081c8d4a.tar.zst pttbbs-a83b090df287faab2600783fb9cb0b9a081c8d4a.zip |
use FNV hash function
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2566 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util')
-rw-r--r-- | util/poststat.c | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/util/poststat.c b/util/poststat.c index f89d2109..b300e961 100644 --- a/util/poststat.c +++ b/util/poststat.c @@ -2,6 +2,7 @@ /* 統計今日、週、月、年熱門話題 */ #include "bbs.h" +#include "fnv_hash.h" char *myfile[] = {"day", "week", "month", "year"}; @@ -78,19 +79,6 @@ ci_strcmp(s1, s2) return 0; } -int -hash(key) - char *key; -{ - int i, value = 0; - - for (i = 0; key[i] && i < 80; i++) - value += key[i] < 0 ? -key[i] : key[i]; - - value = value % HASHSIZE; - return value; -} - /* ---------------------------------- */ /* hash structure : array + link list */ @@ -104,7 +92,7 @@ search(t) struct postrec *p, *q, *s; int i, found = 0; - i = hash(t->title); + i = fnv1a_32_str(t->title, FNV1_32_INIT) % HASHSIZE; q = NULL; p = bucket[i]; while (p && (!found)) |