mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
perf(semantic): reduce memory copies (#4216)
Reduce memory copies when resolving references in `Semantic`. If parent scope has no unresolved references for `name`, there is no need to generate a new `Vec<ReferenceId>` for `name` and copy in contents from current scope. Just move the existing `Vec` to the parent.
This commit is contained in:
parent
ef4c1f4e32
commit
cb15303644
1 changed files with 3 additions and 1 deletions
|
|
@ -389,8 +389,10 @@ impl<'a> SemanticBuilder<'a> {
|
||||||
self.symbols.references[*reference_id].set_symbol_id(symbol_id);
|
self.symbols.references[*reference_id].set_symbol_id(symbol_id);
|
||||||
}
|
}
|
||||||
self.symbols.resolved_references[symbol_id].extend(reference_ids);
|
self.symbols.resolved_references[symbol_id].extend(reference_ids);
|
||||||
|
} else if let Some(parent_reference_ids) = parent_refs.get_mut(&name) {
|
||||||
|
parent_reference_ids.extend(reference_ids);
|
||||||
} else {
|
} else {
|
||||||
parent_refs.entry(name).or_default().extend(reference_ids);
|
parent_refs.insert(name, reference_ids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue