Skip to content

Commit a8e5f6c

Browse files
committed
Fix another bug in the hash table.
Clearing the secondMaps was incorrect for cases where the secondMaps included a wrap around to the start of the table.
1 parent 00c631c commit a8e5f6c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

hash_table.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,10 @@ static void PREFIX(_remove)(PREFIX(_table) *table, void *key)
394394

395395
uint32_t hash = MAP_TABLE_HASH_KEY(key);
396396
PREFIX(_table_cell) baseCell = PREFIX(_table_lookup)(table, hash);
397-
if (baseCell && baseCell < cell && cell - baseCell <= 32)
397+
if (baseCell && baseCell != cell)
398398
{
399-
uint32_t jump = 1 << (cell - baseCell - 1);
399+
uint32_t displacement = (cell - baseCell + table->table_size) % table->table_size;
400+
uint32_t jump = 1 << (displacement - 1);
400401
if ((baseCell->secondMaps & jump))
401402
{
402403
// If we are removing a cell stored adjacent to its base due to hash

0 commit comments

Comments
 (0)