From a6c7eaec1add217e19be26af22d4784cf506353c Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Fri, 18 Mar 2022 01:06:07 +0000 Subject: [PATCH] Correctly calculate new distance to initial bucket --- agb/src/hash_map.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/agb/src/hash_map.rs b/agb/src/hash_map.rs index 922f9dd0..1d65ea5d 100644 --- a/agb/src/hash_map.rs +++ b/agb/src/hash_map.rs @@ -75,10 +75,6 @@ impl NodeStorage { if let Some(current_node) = current_node { if current_node.distance_to_initial_bucket <= new_node.distance_to_initial_bucket { - max_distance_to_initial_bucket = new_node - .distance_to_initial_bucket - .max(max_distance_to_initial_bucket); - mem::swap(&mut new_node, current_node); } } else { @@ -87,6 +83,9 @@ impl NodeStorage { } new_node.distance_to_initial_bucket += 1; + max_distance_to_initial_bucket = new_node + .distance_to_initial_bucket + .max(max_distance_to_initial_bucket); } max_distance_to_initial_bucket