14 lines
253 B
C
14 lines
253 B
C
#include "hash/djb2.h"
|
|
|
|
/*
|
|
* Simple hash function djb2, as in Daniel J. Berenstein.
|
|
*/
|
|
|
|
uint64_t djb2(const char *str) {
|
|
uint64_t h = 5381;
|
|
int c;
|
|
|
|
while ((c = *str++)) h = ((h << 5) + h) + c; // h = h * 33 + c;
|
|
|
|
return h;
|
|
}
|