Skip to content

Commit

Permalink
Fix for the fill behavior of compat-set
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Bormann <ChristianCarl.Bormann@de.bosch.com>
  • Loading branch information
c2bo committed Sep 13, 2022
1 parent cd0d349 commit 293e764
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions indy_common/compat_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,16 @@ def insert_entry_clean(self, entry: _Entry):
while True:
if table[i] is None:
table[i] = entry
self._fill += 1
self._used += 1
return

if i + LINEAR_PROBES <= mask:
for j in range(i + 1, i + LINEAR_PROBES + 1):
if table[j] is None:
table[j] = entry
self._fill += 1
self._used += 1
return

perturb >>= PERTURB_SHIFT
Expand Down Expand Up @@ -444,18 +448,17 @@ def pop(self):

def resize(self, min_used: int):
"""Adjust the allocated size of the set."""
old_fill = self._fill
old_table = self._table
assert min_used >= 0

new_size = MIN_SIZE
while new_size <= min_used:
new_size <<= 1
new_size = new_size * 2

self._table = [None] * new_size
self._fill = old_fill
self._fill = 0
self._mask = new_size - 1
self._used = old_fill
self._used = 0

for entry in old_table:
if entry is not None and entry is not REMOVED:
Expand Down

0 comments on commit 293e764

Please sign in to comment.