summaryrefslogtreecommitdiff
path: root/rts/Hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'rts/Hash.c')
-rw-r--r--rts/Hash.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/rts/Hash.c b/rts/Hash.c
index 8f32ac3076..702e5a20a7 100644
--- a/rts/Hash.c
+++ b/rts/Hash.c
@@ -13,6 +13,7 @@
#include "Hash.h"
#include "RtsUtils.h"
+#include "xxhash.h"
#include <string.h>
@@ -78,18 +79,14 @@ hashWord(const HashTable *table, StgWord key)
int
hashStr(const HashTable *table, char *key)
{
- int h, bucket;
- char *s;
-
- s = key;
- for (h=0; *s; s++) {
- h *= 128;
- h += *s;
- h = h % 1048583; /* some random large prime */
- }
+#if x86_64_HOST_ARCH
+ StgWord h = XXH64 (key, strlen(key), 1048583);
+#else
+ StgWord h = XXH32 (key, strlen(key), 1048583);
+#endif
/* Mod the size of the hash table (a power of 2) */
- bucket = h & table->mask1;
+ int bucket = h & table->mask1;
if (bucket < table->split) {
/* Mod the size of the expanded hash table (also a power of 2) */