Also use exponential probing during lookups

This commit is contained in:
Vftdan 2024-02-25 15:37:11 +01:00
parent c5035fba81
commit c3af4ce4be
1 changed files with 1 additions and 2 deletions

View File

@ -388,8 +388,7 @@ void sfx_pool_grow(int size) {
struct sfx_pool_item *sfx_pool_lookup(const char *key) { struct sfx_pool_item *sfx_pool_lookup(const char *key) {
if (key == NULL) return NULL; if (key == NULL) return NULL;
uint32_t hash = adler32(key, strlen(key)); uint32_t hash = adler32(key, strlen(key));
for (int offset = 0; offset < sounds_pool.cap; offset++) { FOR_OFFSET_PROBE (hash, offset, index, sounds_pool.cap) {
int index = (hash + offset) % sounds_pool.cap;
if (0 == strncmp(key, sounds_pool.sounds[index].key, KEY_LENGTH)) { if (0 == strncmp(key, sounds_pool.sounds[index].key, KEY_LENGTH)) {
#ifndef NO_COUNTERS #ifndef NO_COUNTERS
global_counters.pool_read++; global_counters.pool_read++;