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

perf(traverse): speed up finding UID binding name #4356

Merged
Merged
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
17 changes: 2 additions & 15 deletions crates/oxc_traverse/src/context/scoping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,21 +447,8 @@ impl TraverseScoping {
}

fn name_is_unique(&self, name: &str) -> bool {
// Check if any bindings in program with this name
if self.symbols.names.iter().any(|n| n.as_str() == name) {
return false;
}

// Check for unbound references in program with this name
!self.symbols.references.iter().any(|reference| {
if reference.symbol_id().is_some() {
// Skip string comparison on bound references, as they'll also be in `symbols.names`
// which already checked above
false
} else {
reference.name().as_str() == name
}
})
!self.scopes.root_unresolved_references().contains_key(name)
&& !self.symbols.names.iter().any(|n| n.as_str() == name)
}
}

Expand Down