Also use exponential probing during lookups
This commit is contained in:
parent
c5035fba81
commit
c3af4ce4be
|
@ -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++;
|
||||||
|
|
Loading…
Reference in New Issue