From 0b0393afc109ec5fbc2d2ce5bcd4b2ebc9e2e9eb Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Wed, 1 Jan 2020 16:53:39 -0500 Subject: Factor out hashing function --- litterbox.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'litterbox.c') diff --git a/litterbox.c b/litterbox.c index 2ab2bf1..88f342e 100644 --- a/litterbox.c +++ b/litterbox.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -192,14 +191,7 @@ static void handleReplyEndOfMOTD(struct Message *msg) { } static int color(const char *user) { - if (*user == '~') user++; - uint32_t hash = 0; - for (; *user; ++user) { - hash = (hash << 5) | (hash >> 27); - hash ^= *user; - hash *= 0x27220A95; - } - return 2 + hash % 14; + return 2 + hash(user) % 14; } static void querySearch(struct Message *msg) { -- cgit 1.4.1