diff options
| author | chenzizhan <[email protected]> | 2024-07-04 18:21:10 +0800 |
|---|---|---|
| committer | chenzizhan <[email protected]> | 2024-07-04 18:21:10 +0800 |
| commit | 9573160d04b5285f1657bc966b779ae69c190c23 (patch) | |
| tree | 1faf42585035eefce4ec81b59c0e19f319dd1d14 /src | |
| parent | 848b9ce1453b0a551920a1345c0279887a0ab96a (diff) | |
use xxhash cal hash
Diffstat (limited to 'src')
| -rw-r--r-- | src/tags/heavy_keeper.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/tags/heavy_keeper.c b/src/tags/heavy_keeper.c index 76ccefa..49e9b3b 100644 --- a/src/tags/heavy_keeper.c +++ b/src/tags/heavy_keeper.c @@ -12,9 +12,17 @@ #include "minheap/heap.h" #include "mpack/mpack.h" -#include "uthash.h" #include "xxhash/xxhash.h" + +// XXHASH is faster +#define HASH_FUNCTION(keyptr, keylen, hashv) \ + do { \ + hashv = XXH3_64bits(keyptr, keylen); \ + } while (0) + +#include "uthash.h" + #include "exdata.h" #define FP_HASH_KEY 0 @@ -635,7 +643,7 @@ int heavy_keeper_add(struct heavy_keeper *heavy_keeper, const char *key, size_t return 1; } unsigned nMin = sorted_set_get_min_count(summary); - if (nMin == INVALID_COUNT || maxv > nMin) { + if (maxv > nMin || nMin == INVALID_COUNT) { sorted_set_insert(summary, key, key_len, maxv, arg); return 1; } |
