mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
Memoize block_item_tree_query
This commit is contained in:
parent
fde2d9b47c
commit
bfad781a77
2 changed files with 4 additions and 5 deletions
|
@ -83,9 +83,6 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDataba
|
|||
fn file_item_tree(&self, file_id: HirFileId) -> Arc<ItemTree>;
|
||||
|
||||
#[salsa::invoke(ItemTree::block_item_tree_query)]
|
||||
// FIXME: Investigate memory usage increase if this were not transparent
|
||||
// Also make sure to `shrink_to_fit` if you do
|
||||
#[salsa::transparent]
|
||||
fn block_item_tree_query(&self, block_id: BlockId) -> Arc<ItemTree>;
|
||||
|
||||
#[salsa::invoke(crate_def_map_wait)]
|
||||
|
|
|
@ -148,7 +148,9 @@ impl ItemTree {
|
|||
let block = loc.ast_id.to_node(db.upcast());
|
||||
|
||||
let ctx = lower::Ctx::new(db, loc.ast_id.file_id);
|
||||
Arc::new(ctx.lower_block(&block))
|
||||
let mut item_tree = ctx.lower_block(&block);
|
||||
item_tree.shrink_to_fit();
|
||||
Arc::new(item_tree)
|
||||
}
|
||||
|
||||
/// Returns an iterator over all items located at the top level of the `HirFileId` this
|
||||
|
@ -383,7 +385,7 @@ impl TreeId {
|
|||
|
||||
pub(crate) fn item_tree(&self, db: &dyn DefDatabase) -> Arc<ItemTree> {
|
||||
match self.block {
|
||||
Some(block) => ItemTree::block_item_tree_query(db, block),
|
||||
Some(block) => db.block_item_tree_query(block),
|
||||
None => db.file_item_tree(self.file),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue