mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
perf(semantic): reduce lookups (#4214)
Small performance optimization (I hope) to resolving references in `Semantic`. Look up current bindings once rather than on every turn of the loop.
This commit is contained in:
parent
f23e54f97b
commit
ef4c1f4e32
1 changed files with 2 additions and 1 deletions
|
|
@ -380,10 +380,11 @@ impl<'a> SemanticBuilder<'a> {
|
|||
let parent_refs = iter.nth(self.current_scope_depth - 1).unwrap();
|
||||
let current_refs = iter.next().unwrap();
|
||||
|
||||
let bindings = self.scope.get_bindings(self.current_scope_id);
|
||||
for (name, reference_ids) in current_refs.drain() {
|
||||
// Try to resolve a reference.
|
||||
// If unresolved, transfer it to parent scope's unresolved references.
|
||||
if let Some(symbol_id) = self.scope.get_binding(self.current_scope_id, &name) {
|
||||
if let Some(symbol_id) = bindings.get(&name).copied() {
|
||||
for reference_id in &reference_ids {
|
||||
self.symbols.references[*reference_id].set_symbol_id(symbol_id);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue