Wrong miss calculation on sfx_pool_grow

This commit is contained in:
Casey 2024-04-22 15:25:43 +03:00
parent b68a4b7ccb
commit 5dc7e334b2
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
1 changed files with 6 additions and 6 deletions

View File

@ -378,13 +378,13 @@ void sfx_pool_grow(int size) {
uint32_t new_hash = adler32(sounds_pool.sounds[i].key, strlen(sounds_pool.sounds[i].key)); uint32_t new_hash = adler32(sounds_pool.sounds[i].key, strlen(sounds_pool.sounds[i].key));
for (int offset = 0; offset < size; offset++) { for (int offset = 0; offset < size; offset++) {
int index = (new_hash + offset) % size; int index = (new_hash + offset) % size;
if (new_items[index].key[0] == '\0') {
#ifndef NO_COUNTERS #ifndef NO_COUNTERS
global_counters.pool_write++;
if (offset != 0) { if (offset != 0) {
global_counters.hash_misses_write++; global_counters.hash_misses_write++;
} }
global_counters.pool_write++;
#endif #endif
if (new_items[index].key[0] == '\0') {
memcpy(&new_items[index], &sounds_pool.sounds[i], sizeof(struct sfx_pool_item)); memcpy(&new_items[index], &sounds_pool.sounds[i], sizeof(struct sfx_pool_item));
used++; used++;
break; break;