diff --git a/agb/src/hash_map.rs b/agb/src/hash_map.rs index 273e3784..922f9dd0 100644 --- a/agb/src/hash_map.rs +++ b/agb/src/hash_map.rs @@ -98,10 +98,18 @@ impl NodeStorage { let result = loop { 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 self.0[next_location].is_none() { + // if the next node is empty, or the next location has 0 distance to initial bucket then + // 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(); } + if self.0[next_location].is_none() {} self.0.swap(current_location, next_location); self.0[current_location]