projects
/
redis.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Contextualize comment.
[redis.git]
/
src
/
dict.c
diff --git
a/src/dict.c
b/src/dict.c
index a573bcd6e3575477f1e58c67811b46122972de88..53e16be0ff22a1090cee4449c8813ce37050cc13 100644
(file)
--- a/
src/dict.c
+++ b/
src/dict.c
@@
-85,10
+85,20
@@
unsigned int dictIdentityHashFunction(unsigned int key)
return key;
}
return key;
}
+static int dict_hash_function_seed = 5381;
+
+void dictSetHashFunctionSeed(unsigned int seed) {
+ dict_hash_function_seed = seed;
+}
+
+unsigned int dictGetHashFunctionSeed(void) {
+ return dict_hash_function_seed;
+}
+
/* Generic hash function (a popular one from Bernstein).
* I tested a few and this was the best. */
unsigned int dictGenHashFunction(const unsigned char *buf, int len) {
/* Generic hash function (a popular one from Bernstein).
* I tested a few and this was the best. */
unsigned int dictGenHashFunction(const unsigned char *buf, int len) {
- unsigned int hash =
5381
;
+ unsigned int hash =
dict_hash_function_seed
;
while (len--)
hash = ((hash << 5) + hash) + (*buf++); /* hash * 33 + c */
while (len--)
hash = ((hash << 5) + hash) + (*buf++); /* hash * 33 + c */
@@
-97,7
+107,7
@@
unsigned int dictGenHashFunction(const unsigned char *buf, int len) {
/* And a case insensitive version */
unsigned int dictGenCaseHashFunction(const unsigned char *buf, int len) {
/* And a case insensitive version */
unsigned int dictGenCaseHashFunction(const unsigned char *buf, int len) {
- unsigned int hash =
5381
;
+ unsigned int hash =
dict_hash_function_seed
;
while (len--)
hash = ((hash << 5) + hash) + (tolower(*buf++)); /* hash * 33 + c */
while (len--)
hash = ((hash << 5) + hash) + (tolower(*buf++)); /* hash * 33 + c */