Fix issue where we weren't considering 0 distance correctly

This commit is contained in:
Gwilym Kuiper 2022-03-18 00:53:18 +00:00
parent f7eb1866c2
commit 12dab0c3ba

View file

@ -98,10 +98,18 @@ impl<K, V> NodeStorage<K, V> {
let result = loop { let result = loop {
let next_location = fast_mod(self.len(), (current_location + 1) as HashType); let next_location = fast_mod(self.len(), (current_location + 1) as HashType);
// if the next node is empty, then we can clear the current node // if the next node is empty, or the next location has 0 distance to initial bucket then
if self.0[next_location].is_none() { // we can clear the current node
if self.0[next_location].is_none()
|| self.0[next_location]
.as_ref()
.unwrap()
.distance_to_initial_bucket
== 0
{
break self.0[current_location].take().unwrap(); break self.0[current_location].take().unwrap();
} }
if self.0[next_location].is_none() {}
self.0.swap(current_location, next_location); self.0.swap(current_location, next_location);
self.0[current_location] self.0[current_location]