Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit 5f9f4ae

Browse files
author
Hendrik van Antwerpen
committed
Use HashArena for symbol stack keys
1 parent b4b84ea commit 5f9f4ae

1 file changed

Lines changed: 3 additions & 16 deletions

File tree

stack-graphs/src/stitching.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
//! [`Database`]: struct.Database.html
3636
//! [`PathStitcher`]: struct.PathStitcher.html
3737
38-
use std::collections::HashMap;
3938
use std::collections::VecDeque;
4039
#[cfg(feature = "copious-debugging")]
4140
use std::fmt::Display;
@@ -44,6 +43,7 @@ use std::ops::Index;
4443
use crate::arena::Arena;
4544
use crate::arena::Handle;
4645
use crate::arena::HandleSet;
46+
use crate::arena::HashArena;
4747
use crate::arena::List;
4848
use crate::arena::ListCell;
4949
use crate::arena::SupplementalArena;
@@ -76,8 +76,7 @@ use crate::CancellationFlag;
7676
pub struct Database {
7777
pub(crate) partial_paths: VecArena<PartialPath>,
7878
pub(crate) local_nodes: HandleSet<Node>,
79-
symbol_stack_keys: VecArena<ListCell<Handle<Symbol>>>,
80-
symbol_stack_key_cache: HashMap<SymbolStackCacheKey, SymbolStackKeyHandle>,
79+
symbol_stack_keys: HashArena<ListCell<Handle<Symbol>>>,
8180
paths_by_start_node: SupplementalArena<Node, Vec<Handle<PartialPath>>>,
8281
root_paths_by_precondition: SupplementalArena<SymbolStackKeyCell, Vec<Handle<PartialPath>>>,
8382
}
@@ -88,8 +87,7 @@ impl Database {
8887
Database {
8988
partial_paths: VecArena::new(),
9089
local_nodes: HandleSet::new(),
91-
symbol_stack_keys: VecArena::new(),
92-
symbol_stack_key_cache: HashMap::new(),
90+
symbol_stack_keys: HashArena::new(),
9391
paths_by_start_node: SupplementalArena::new(),
9492
root_paths_by_precondition: SupplementalArena::new(),
9593
}
@@ -362,18 +360,7 @@ impl SymbolStackKey {
362360

363361
/// Pushes a new symbol onto the back of this symbol stack key.
364362
fn push_back(&mut self, db: &mut Database, symbol: Handle<Symbol>) {
365-
let cache_key = SymbolStackCacheKey {
366-
head: symbol,
367-
tail: self.back_handle(),
368-
};
369-
if let Some(handle) = db.symbol_stack_key_cache.get(&cache_key) {
370-
self.symbols = List::from_handle(*handle);
371-
return;
372-
}
373-
// push_front because we store the key's symbols in reverse order.
374363
self.symbols.push_front(&mut db.symbol_stack_keys, symbol);
375-
let handle = self.back_handle();
376-
db.symbol_stack_key_cache.insert(cache_key, handle);
377364
}
378365

379366
/// Pops a symbol from the back of this symbol stack key.

0 commit comments

Comments
 (0)