X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/89f9f83769a2ad0b4aeb8907b82b453ace6ebe9d..ac06fc011df598372232a5dc1805683004240c0d:/src/dict.c diff --git a/src/dict.c b/src/dict.c index a1060d45..9be7fb16 100644 --- a/src/dict.c +++ b/src/dict.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "dict.h" #include "zmalloc.h" @@ -94,6 +95,15 @@ unsigned int dictGenHashFunction(const unsigned char *buf, int len) { return hash; } +/* And a case insensitive version */ +unsigned int dictGenCaseHashFunction(const unsigned char *buf, int len) { + unsigned int hash = 5381; + + while (len--) + hash = ((hash << 5) + hash) + (tolower(*buf++)); /* hash * 33 + c */ + return hash; +} + /* ----------------------------- API implementation ------------------------- */ /* Reset an hashtable already initialized with ht_init().