[varStore] Minor adjustment to the optimize() algorithm

It's very unlikely that this path is needed, but it's correct
to have it.
This commit is contained in:
Behdad Esfahbod 2023-05-25 07:00:28 -06:00
parent 5255c01bcc
commit c1ab8995f2

View File

@ -647,6 +647,14 @@ def VarStore_optimize(self, use_NO_VARIATION_INDEX=True, quantization=1):
combined_encoding.extend(other_encoding.items)
combined_encoding._find_yourself_best_new_encoding(done_by_width)
del todo[best_idx]
# In the unlikely event that the same encoding exists already,
# combine; otherwise add it back to the todo list.
for enc in todo:
if enc.chars == combined_chars:
enc.extend(combined_encoding.items)
break
else:
todo.append(combined_encoding)
# Assemble final store.