chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
hashmap: use different version of DJB's hash algorithm that uses shifting instead...
[elogind.git]
/
src
/
hashmap.c
diff --git
a/src/hashmap.c
b/src/hashmap.c
index 0d89da461406b30b022b0760289acd20e457b217..95ea45da4893662d42b569f16914acf6ec4101e9 100644
(file)
--- a/
src/hashmap.c
+++ b/
src/hashmap.c
@@
-124,11
+124,13
@@
__attribute__((destructor)) static void cleanup_pool(void) {
#endif
unsigned string_hash_func(const void *p) {
#endif
unsigned string_hash_func(const void *p) {
- unsigned hash = 0;
- const char *c;
+ unsigned hash = 5381;
+ const signed char *c;
+
+ /* DJB's hash function */
for (c = p; *c; c++)
for (c = p; *c; c++)
- hash =
31 *
hash + (unsigned) *c;
+ hash =
(hash << 5) +
hash + (unsigned) *c;
return hash;
}
return hash;
}