mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
refactor(semantic): do not reserve space in resolved_references (#4962)
While resolving references in `SemanticBuilder`, there is little benefit to reserving space in advance in `resolved_references` as it is not possible to avoid growing the `Vec`. The comment here says "Reserve space for all references to avoid reallocations", but `reserve()` itself may cause a reallocation.
This commit is contained in:
parent
a7ef30dcf9
commit
d677b8e0ab
1 changed files with 1 additions and 4 deletions
|
|
@ -466,10 +466,7 @@ impl<'a> SemanticBuilder<'a> {
|
|||
if let Some(symbol_id) = bindings.get(name.as_str()).copied() {
|
||||
let symbol_flag = self.symbols.get_flag(symbol_id);
|
||||
|
||||
let resolved_references: &mut Vec<_> =
|
||||
self.symbols.resolved_references[symbol_id].as_mut();
|
||||
// Reserve space for all references to avoid reallocations.
|
||||
resolved_references.reserve(references.len());
|
||||
let resolved_references = &mut self.symbols.resolved_references[symbol_id];
|
||||
|
||||
references.retain(|&reference_id| {
|
||||
let reference = &mut self.symbols.references[reference_id];
|
||||
|
|
|
|||
Loading…
Reference in a new issue