mirror of
https://github.com/systemd/systemd.git
synced 2024-11-07 01:27:11 +03:00
hashmap: use different version of DJB's hash algorithm that uses shifting instead of multiplication
This commit is contained in:
parent
340047e95d
commit
7dfe96eebc
@ -124,11 +124,13 @@ __attribute__((destructor)) static void cleanup_pool(void) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned string_hash_func(const void *p) {
|
unsigned string_hash_func(const void *p) {
|
||||||
unsigned hash = 0;
|
unsigned hash = 5381;
|
||||||
const char *c;
|
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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user