diff options
| author | mat <git@matdoes.dev> | 2023-10-05 01:40:25 -0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-10-05 01:40:25 -0500 |
| commit | 177864be60c08cb61fd577eb99ee5c99481fc03e (patch) | |
| tree | 982fbe6430b1818fec7134e26378fd5f626a1ed4 /azalea/src/pathfinder/astar.rs | |
| parent | e4e0433853d1e2d9d95d4269700df032db9dd913 (diff) | |
| download | azalea-drasl-177864be60c08cb61fd577eb99ee5c99481fc03e.tar.xz | |
replace a linear search with a binary search . . .
Diffstat (limited to 'azalea/src/pathfinder/astar.rs')
| -rw-r--r-- | azalea/src/pathfinder/astar.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/azalea/src/pathfinder/astar.rs b/azalea/src/pathfinder/astar.rs index 4e1d1039..98525e03 100644 --- a/azalea/src/pathfinder/astar.rs +++ b/azalea/src/pathfinder/astar.rs @@ -1,6 +1,5 @@ use std::{ cmp::Reverse, - collections::HashMap, fmt::Debug, hash::Hash, time::{Duration, Instant}, @@ -8,6 +7,7 @@ use std::{ use log::{debug, trace, warn}; use priority_queue::PriorityQueue; +use rustc_hash::FxHashMap; pub struct Path<P, M> where @@ -40,7 +40,7 @@ where let mut open_set = PriorityQueue::new(); open_set.push(start, Reverse(Weight(0.))); - let mut nodes: HashMap<P, Node<P, M>> = HashMap::new(); + let mut nodes: FxHashMap<P, Node<P, M>> = FxHashMap::default(); nodes.insert( start, Node { @@ -134,7 +134,7 @@ where best_paths[0] } -fn reconstruct_path<P, M>(mut nodes: HashMap<P, Node<P, M>>, current: P) -> Vec<Movement<P, M>> +fn reconstruct_path<P, M>(mut nodes: FxHashMap<P, Node<P, M>>, current: P) -> Vec<Movement<P, M>> where P: Eq + Hash + Copy + Debug, { |
