perf(parser): reuse shorthand assignment target identifiers (#28504)

Reuse the parsed shorthand identifier when building assignment targets,
avoiding duplicate node construction.

AI-assisted implementation.
This commit is contained in:
Boshen authored and GitHub committed 2026-10-30 17:17:32 +08:00
1 parent 444f24ad82
commit babf44cc96
1 file changed
+2 -5
+2 -5
View File
@@ -228,11 +228,8 @@ impl<'a, C: Config> CoverGrammar<'a, ObjectExpression<'a>, C> for ObjectAssignme
impl<'a, C: Config> CoverGrammar<'a, ObjectProperty<'a>, C> for AssignmentTargetProperty<'a> {
fn cover(property: ObjectProperty<'a>, p: &mut ParserImpl<'a, C>) -> Self {
if property.shorthand {
let binding = match property.key {
PropertyKey::StaticIdentifier(ident) => {
let ident = ident.unbox();
IdentifierReference::new(ident.span, ident.name, p)
}
let binding = match property.value {
Expression::Identifier(ident) => ident.unbox(),
_ => return p.unexpected(),
};
// convert `CoverInitializedName`