From 12dab0c3babbb644ed1b961918c331fb15f31cdf Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Fri, 18 Mar 2022 00:53:18 +0000 Subject: [PATCH] Fix issue where we weren't considering 0 distance correctly --- agb/src/hash_map.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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]