From 9fd3b45c0e48f8792492425df13a3fe3baccc849 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Wed, 26 Feb 2025 14:28:05 -0500 Subject: [PATCH] move comment regarding FutureMoves::by_depth --- src/logic/future_moves.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/logic/future_moves.rs b/src/logic/future_moves.rs index 5429a9b..7718f7c 100644 --- a/src/logic/future_moves.rs +++ b/src/logic/future_moves.rs @@ -151,12 +151,16 @@ impl FutureMoves { depth - 1 } + //// PERF! pre-organize all indexes based on what depth they're at + /// previously, I did a lookup map based on if a node was visited, still resulted in a full + /// O(n) iteration each depth fn by_depth(&self, indexes: impl Iterator) -> Vec<(usize, Vec)> { let mut by_depth: HashMap< usize, Vec, BuildHasherDefault>, > = HashMap::with_hasher(BuildHasherDefault::default()); + for idx in indexes { let depth = self.depth_of(idx); if let Some(got) = by_depth.get_mut(&depth) { @@ -173,9 +177,6 @@ impl FutureMoves { /// Compute `Move.value`, propegating upwards from the furthest out Moves /// in the Arena. fn compute_values(&mut self, indexes: impl Iterator) { - // PERF! pre-organize all indexes based on what depth they're at - // previously, I did a lookup map based on if a node was visited, still resulted in a full - // O(n) iteration each depth let by_depth_vec = self.by_depth(indexes); // reversed so we build up the value of the closest (in time) moves from the future