mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 01:15:12 +03:00
Whoops, forgot to not leak all the RAMs
This commit is contained in:
parent
006839aec2
commit
08223efed5
@ -230,6 +230,10 @@ impl<K: Clone + PartialEq, V> VecMap<K, V> {
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.inner.is_empty()
|
||||
}
|
||||
|
||||
pub fn clear(&mut self) {
|
||||
self.inner.clear();
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: Clone + PartialEq, V> Default for VecMap<K, V> {
|
||||
|
@ -115,6 +115,10 @@ impl State<App> for RoutePlanner {
|
||||
let panel_outcome = self.panel.event(ctx);
|
||||
if let Outcome::Clicked(ref x) = panel_outcome {
|
||||
if x == "Back to editing modal filters" {
|
||||
// We'll cache a custom pathfinder per set of avoided roads. Avoid leaking memory
|
||||
// by clearing this out
|
||||
app.primary.map.clear_custom_pathfinder_cache();
|
||||
|
||||
return Transition::ConsumeState(Box::new(|state, ctx, app| {
|
||||
let state = state.downcast::<RoutePlanner>().ok().unwrap();
|
||||
vec![super::viewer::Viewer::new_state(
|
||||
|
@ -605,6 +605,11 @@ impl Map {
|
||||
self.pathfinder.should_use_transit(self, start, end)
|
||||
}
|
||||
|
||||
/// Clear any pathfinders with custom RoutingParams, created previously with `cache_custom`
|
||||
pub fn clear_custom_pathfinder_cache(&self) {
|
||||
self.pathfinder.clear_custom_pathfinder_cache();
|
||||
}
|
||||
|
||||
/// Return the cost of a single path, and also a mapping from every directed road to the cost
|
||||
/// of getting there from the same start. This can be used to understand why an alternative
|
||||
/// route wasn't chosen.
|
||||
|
@ -213,6 +213,13 @@ impl Pathfinder {
|
||||
result
|
||||
}
|
||||
|
||||
pub fn clear_custom_pathfinder_cache(&self) {
|
||||
self.cached_alternatives
|
||||
.get_or(|| RefCell::new(VecMap::new()))
|
||||
.borrow_mut()
|
||||
.clear();
|
||||
}
|
||||
|
||||
pub fn all_costs_from(
|
||||
&self,
|
||||
req: PathRequest,
|
||||
|
Loading…
Reference in New Issue
Block a user