diff --git a/strutil.c b/strutil.c index c02490f..4c9ef4d 100644 --- a/strutil.c +++ b/strutil.c @@ -2,10 +2,10 @@ #include "string.h" uintptr_t strnhash(const char* s, size_t n) { - static const size_t shift = sizeof(uintptr_t) * 8 - 4; uintptr_t hash = 0; + static size_t const a = 33; for(size_t i = 0; i < n; ++i) { - hash = ((hash << 4) | s[i]) ^ (((uintptr_t)0xF << shift) & hash); + hash = ((hash*a) + s[i]); } return hash; }