summaryrefslogtreecommitdiffstats
path: root/src/libutil/uthash_strcase.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/uthash_strcase.h')
-rw-r--r--src/libutil/uthash_strcase.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libutil/uthash_strcase.h b/src/libutil/uthash_strcase.h
index 1b4024cc6..4e28f3110 100644
--- a/src/libutil/uthash_strcase.h
+++ b/src/libutil/uthash_strcase.h
@@ -25,13 +25,28 @@
#include "xxhash.h"
+
/* Utils for uthash tuning */
+#ifndef HASH_CASELESS
#define HASH_FUNCTION(key,keylen,num_bkts,hashv,bkt) do {\
hashv = XXH32(key, keylen, 0); \
bkt = (hashv) & (num_bkts-1); \
} while (0)
+#define HASH_KEYCMP(a,b,len) memcmp(a,b,len)
+#else
+#define HASH_FUNCTION(key,keylen,num_bkts,hashv,bkt) do {\
+ void *xxh = XXH32_init(0xdead); \
+ unsigned char *p = (unsigned char *)key, t; \
+ for (unsigned int i = 0; i < keylen; i ++) { \
+ t = g_ascii_tolower(p[i]); \
+ XXH32_update(xxh, &t, 1); \
+ } \
+ hashv = XXH32_digest(xxh); \
+ bkt = (hashv) & (num_bkts-1); \
+} while (0)
#define HASH_KEYCMP(a,b,len) strncasecmp(a,b,len)
+#endif
#include "uthash.h"