Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pref(semantic): reserve space for resolved_refrences #8011

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion crates/oxc_semantic/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,15 +484,20 @@ impl<'a> SemanticBuilder<'a> {
/// This gets called every time [`SemanticBuilder`] exits a scope.
fn resolve_references_for_current_scope(&mut self) {
let (current_refs, parent_refs) = self.unresolved_references.current_and_parent_mut();
let bindings = self.scope.get_bindings(self.current_scope_id);

for (name, mut references) in current_refs.drain() {
// Try to resolve a reference.
// If unresolved, transfer it to parent scope's unresolved references.
let bindings = self.scope.get_bindings(self.current_scope_id);
if let Some(symbol_id) = bindings.get(name.as_str()).copied() {
let symbol_flags = self.symbols.get_flags(symbol_id);
let references_len = references.len();

references.retain(|&reference_id| {
let reference = &mut self.symbols.references[reference_id];
if references_len > 64 {
self.symbols.resolved_references.reserve(references_len);
}

let flags = reference.flags_mut();

Expand Down
Loading