--- dictionary.h.orig 2025-11-23 21:53:24.284418000 +0000 +++ dictionary.h 2025-11-23 21:53:49.343390000 +0000 @@ -15,7 +15,7 @@ static_assert(pair == 2, ""); -enum bucket {bucket = pair}; +enum bucket {distance = pair, bucket}; #define compiled(ARRAY) ( \ assert((ARRAY).type == arraytype), \ --- dictionary.c.orig 2025-11-23 21:53:06.913261000 +0000 +++ dictionary.c 2025-11-23 21:53:44.184170000 +0000 @@ -64,6 +64,7 @@ assert(table); table[entry][key] = new[key]; table[entry][value] = new[value]; + table[entry][distance] = new[distance]; return dictionary; } @@ -81,7 +82,18 @@ dictionary.dict = writevm(dictionary.dict); (void)enter(thing, entry, dictionary).dict->length++; return; - } + } else if (thing[distance].integer > table[entry][distance].integer) { + const object displaced[bucket] = { + [key] = table[entry][key], + [value] = table[entry][value], + [distance] = table[entry][distance] + }; + dictionary = enter(thing, entry, dictionary); + thing[key] = displaced[key]; + thing[value] = displaced[value]; + thing[distance] = displaced[distance]; + } + thing[distance].integer++; } while ((++entry, entry &= mask) != start); throw (dictfull); }