Slightly shrink DefMap

This commit is contained in:
Lukas Wirth 2023-06-01 14:46:36 +02:00
parent 117f9b7752
commit dc7c6d43c7
22 changed files with 130 additions and 92 deletions

View file

@ -586,8 +586,9 @@ impl Resolver {
}));
if let Some(block) = expr_scopes.block(scope_id) {
let def_map = db.block_def_map(block);
let root = def_map.root();
resolver.scopes.push(Scope::BlockScope(ModuleItemMap { def_map, module_id: root }));
resolver
.scopes
.push(Scope::BlockScope(ModuleItemMap { def_map, module_id: DefMap::ROOT }));
// FIXME: This adds as many module scopes as there are blocks, but resolving in each
// already traverses all parents, so this is O(n²). I think we could only store the
// innermost module scope instead?
@ -753,8 +754,7 @@ fn resolver_for_scope_(
for scope in scope_chain.into_iter().rev() {
if let Some(block) = scopes.block(scope) {
let def_map = db.block_def_map(block);
let root = def_map.root();
r = r.push_block_scope(def_map, root);
r = r.push_block_scope(def_map, DefMap::ROOT);
// FIXME: This adds as many module scopes as there are blocks, but resolving in each
// already traverses all parents, so this is O(n²). I think we could only store the
// innermost module scope instead?