summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hashmap.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/hashmap.c b/src/hashmap.c
index 0d89da4614..95ea45da48 100644
--- a/src/hashmap.c
+++ b/src/hashmap.c
@@ -124,11 +124,13 @@ __attribute__((destructor)) static void cleanup_pool(void) {
#endif
unsigned string_hash_func(const void *p) {
- unsigned hash = 0;
- const char *c;
+ unsigned hash = 5381;
+ const signed char *c;
+
+ /* DJB's hash function */
for (c = p; *c; c++)
- hash = 31 * hash + (unsigned) *c;
+ hash = (hash << 5) + hash + (unsigned) *c;
return hash;
}