diff options
| author | Tyge Løvset <[email protected]> | 2021-10-16 14:59:12 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-10-16 14:59:12 +0200 |
| commit | e78dd0918583a831e90f4c008c369ca143840124 (patch) | |
| tree | 3acc24b28245ddb80807deb29dd8861243e83a04 /include/stc/cmap.h | |
| parent | 36d2e0960ad33ca6d194ca41a17f0834526173d0 (diff) | |
| download | STC-modified-e78dd0918583a831e90f4c008c369ca143840124.tar.gz STC-modified-e78dd0918583a831e90f4c008c369ca143840124.zip | |
More update on hash. Added string_bench.c+cpp.
Diffstat (limited to 'include/stc/cmap.h')
| -rw-r--r-- | include/stc/cmap.h | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/include/stc/cmap.h b/include/stc/cmap.h index 1dc1fd90..b764a717 100644 --- a/include/stc/cmap.h +++ b/include/stc/cmap.h @@ -216,12 +216,10 @@ cx_memb(_erase_at)(Self* self, cx_iter_t it) { #if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_imp)
#ifndef CMAP_H_INCLUDED
-#define _c_rotl(x, k) (x << (k) | x >> (8*sizeof(x) - (k)))
STC_INLINE uint64_t c_default_hash(const void *key, size_t len) {
- const char* str = (const char*)key;
+ const char* str = (const char*)key, *e = str + len;
uint64_t h = 0xb5ad4eceda1ce2a9;
- for (size_t i = 0; i < len; ++i)
- h ^= (_c_rotl(h, 4) ^ (h << 13)) + str[i];
+ while (str != e) h = (_c_rotl(h, 4) ^ (h << 13)) + *str++;
return h;
}
|
