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