mirror of
https://github.com/AuxXxilium/eudev.git
synced 2024-12-23 17:20:26 +07: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
|
||||
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user