refactor(router/astar): Have separate statuses for discarded probes and skipped visits

This is mostly to improve readability. Since we don't check the values
of the continue statuses anywhere anyway, this doesn't result in any
changes to code outside of the router/astar module.
This commit is contained in:
Mikolaj Wielgus 2025-05-12 23:30:43 +02:00
parent 776ffb00ad
commit 3bce7f969d
1 changed files with 6 additions and 2 deletions

View File

@ -139,7 +139,9 @@ where
#[derive(Debug)] #[derive(Debug)]
pub enum AstarContinueStatus { pub enum AstarContinueStatus {
Probing, Probing,
ProbingButDiscarded,
Probed, Probed,
VisitSkipped,
Visited, Visited,
} }
@ -211,7 +213,9 @@ where
// No need to add neighbors that we have already reached through a // No need to add neighbors that we have already reached through a
// shorter path than now. // shorter path than now.
if *entry.get() <= next_score { if *entry.get() <= next_score {
return Ok(ControlFlow::Continue(AstarContinueStatus::Probed)); return Ok(ControlFlow::Continue(
AstarContinueStatus::ProbingButDiscarded,
));
} }
entry.insert(next_score); entry.insert(next_score);
} }
@ -250,7 +254,7 @@ where
// If the node has already been visited with an equal or lower score than // If the node has already been visited with an equal or lower score than
// now, then we do not need to re-visit it. // now, then we do not need to re-visit it.
if *entry.get() <= estimate_score { if *entry.get() <= estimate_score {
return Ok(ControlFlow::Continue(AstarContinueStatus::Visited)); return Ok(ControlFlow::Continue(AstarContinueStatus::VisitSkipped));
} }
entry.insert(estimate_score); entry.insert(estimate_score);
} }