* Improved file name hashing, slightly.
authorUrban Wallasch <urban.wallasch@freenet.de>
Thu, 10 Jun 2021 14:22:42 +0000 (16:22 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Thu, 10 Jun 2021 14:22:42 +0000 (16:22 +0200)
db.c
db.h

diff --git a/db.c b/db.c
index 371551dc9e37f42f8c8d7b6a410cd84adbb87347..b7b1f8b3acf839612a333e327243543bcb728be5 100644 (file)
--- a/db.c
+++ b/db.c
@@ -14,8 +14,8 @@
 static inline int_fast16_t nhash(const char *s) {
     int_fast16_t h = 0;
     while ( *s ) {
-        h <<= 1;
-        h |= (h >> NHASH_BITS) & 1;
+        h <<= 3;
+        h |= (h >> NHASH_BITS) & 7;
         h ^= *s++;
     }
     return h & NHASH_MASK;
diff --git a/db.h b/db.h
index 565494f9a7e89a24dd732073a04fc529d2194881..8f9613b2928e3c6ef4a470f1391728ff5410632c 100644 (file)
--- a/db.h
+++ b/db.h
@@ -4,7 +4,7 @@
 #include <stdint.h>
 #include <pthread.h>
 
-#define NHASH_BITS 10
+#define NHASH_BITS 12
 #define NHASH_SIZE (1 << NHASH_BITS)
 #define NHASH_MASK (NHASH_SIZE-1)