summary refs log tree commit diff
path: root/litterbox.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-01-01 16:53:39 -0500
committerJune McEnroe <june@causal.agency>2020-01-01 16:54:04 -0500
commit0b0393afc109ec5fbc2d2ce5bcd4b2ebc9e2e9eb (patch)
tree7750cc80d1fd6d8f81c651ea4baefbbfe280c3d4 /litterbox.c
parentAdd option for custom where expression to scoop (diff)
downloadlitterbox-0b0393afc109ec5fbc2d2ce5bcd4b2ebc9e2e9eb.tar.gz
litterbox-0b0393afc109ec5fbc2d2ce5bcd4b2ebc9e2e9eb.zip
Factor out hashing function
Diffstat (limited to '')
-rw-r--r--litterbox.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/litterbox.c b/litterbox.c
index 2ab2bf1..88f342e 100644
--- a/litterbox.c
+++ b/litterbox.c
@@ -18,7 +18,6 @@
 #include <err.h>
 #include <signal.h>
 #include <stdarg.h>
-#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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) {