projects
/
platform
/
upstream
/
systemd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
340047e
)
hashmap: use different version of DJB's hash algorithm that uses shifting instead...
author
Lennart Poettering
<lennart@poettering.net>
Fri, 7 Oct 2011 19:00:48 +0000
(21:00 +0200)
committer
Lennart Poettering
<lennart@poettering.net>
Fri, 7 Oct 2011 19:00:48 +0000
(21:00 +0200)
src/hashmap.c
patch
|
blob
|
history
diff --git
a/src/hashmap.c
b/src/hashmap.c
index
0d89da4
..
95ea45d
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) {
- unsigned hash = 0;
- const char *c;
+ unsigned hash = 5381;
+ const signed char *c;
+
+ /* DJB's hash function */
for (c = p; *c; c++)
- hash =
31 *
hash + (unsigned) *c;
+ hash =
(hash << 5) +
hash + (unsigned) *c;
return hash;
}