X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/83f39c7ab26e7f7cfa5fb59ca51b768e9ac0facb..f858c11d7d9ca79010dd46a9c8c625e63a9a3ec0:/src/dict.c?ds=sidebyside 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().