mirror of
https://github.com/danbulant/oxc
synced 2026-05-25 12:51:57 +00:00
refactor(transformer/object-rest-spread): avoid multiple symbol lookups (#7420)
`IdentifierReference::is_global_reference` and `MaybeBoundIdentifier::from_identifier_reference` both look up the symbol for the identifier. Do this lookup only once, rather than twice.
This commit is contained in:
parent
779f4798e2
commit
6fd0fcb4ff
1 changed files with 4 additions and 4 deletions
|
|
@ -35,7 +35,7 @@ use oxc_allocator::{CloneIn, GetAddress, Vec as ArenaVec};
|
||||||
use oxc_ast::{ast::*, NONE};
|
use oxc_ast::{ast::*, NONE};
|
||||||
use oxc_diagnostics::OxcDiagnostic;
|
use oxc_diagnostics::OxcDiagnostic;
|
||||||
use oxc_ecmascript::{BoundNames, ToJsString};
|
use oxc_ecmascript::{BoundNames, ToJsString};
|
||||||
use oxc_semantic::{IsGlobalReference, ScopeFlags, ScopeId, SymbolFlags};
|
use oxc_semantic::{ScopeFlags, ScopeId, SymbolFlags};
|
||||||
use oxc_span::{GetSpan, SPAN};
|
use oxc_span::{GetSpan, SPAN};
|
||||||
use oxc_traverse::{Ancestor, MaybeBoundIdentifier, Traverse, TraverseCtx};
|
use oxc_traverse::{Ancestor, MaybeBoundIdentifier, Traverse, TraverseCtx};
|
||||||
|
|
||||||
|
|
@ -998,9 +998,9 @@ impl<'a, 'ctx> ObjectRestSpread<'a, 'ctx> {
|
||||||
}
|
}
|
||||||
*all_primitives = false;
|
*all_primitives = false;
|
||||||
if let Expression::Identifier(ident) = expr {
|
if let Expression::Identifier(ident) = expr {
|
||||||
if !ident.is_global_reference(ctx.symbols()) {
|
let binding = MaybeBoundIdentifier::from_identifier_reference(ident, ctx);
|
||||||
let expr = MaybeBoundIdentifier::from_identifier_reference(ident, ctx)
|
if let Some(binding) = binding.to_bound_identifier() {
|
||||||
.create_read_expression(ctx);
|
let expr = binding.create_read_expression(ctx);
|
||||||
return Some(ArrayExpressionElement::from(expr));
|
return Some(ArrayExpressionElement::from(expr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue