summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--main.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/main.c b/main.c
index e65eb9d..4755b62 100644
--- a/main.c
+++ b/main.c
@@ -498,6 +498,15 @@ uint64_t str_hash(Str s) {
 	return h;
 }
 
+uint64_t murmur64(uint64_t h) {
+	h ^= h >> 33;
+	h *= 0xff51afd7ed558ccdL;
+	h ^= h >> 33;
+	h *= 0xc4ceb9fe1a85ec53L;
+	h ^= h >> 33;
+	return h;
+}
+
 /* --hvar bgcolor:'#fcc,#cfc,#ccf,#cff,#ffc,#fcf' */
 int hvar_calc(Str param, Str *name, Str *val, Str filename) {
 	Cut c = str_cut(param, ':');
@@ -506,7 +515,7 @@ int hvar_calc(Str param, Str *name, Str *val, Str filename) {
 	usize n = 0;
 	for (Str h = c.tail; h.n > 0; h = str_cut(h, ',').tail) n++;
 	if (!n) return -1;
-	usize j = str_hash(filename) % n;
+	usize j = murmur64(str_hash(filename)) % n;
 	usize i = 0;
 	for (Str h = c.tail; h.n > 0; h = str_cut(h, ',').tail) {
 		if (i == j) {