Skip to content

perf(parser): avoid redundant IdentifierReference clone in shorthand property#21511

Merged
Boshen merged 1 commit into
mainfrom
perf/parser-shorthand-ident-clone
Apr 17, 2026
Merged

perf(parser): avoid redundant IdentifierReference clone in shorthand property#21511
Boshen merged 1 commit into
mainfrom
perf/parser-shorthand-ident-clone

Conversation

@Boshen

@Boshen Boshen commented Apr 16, 2026

Copy link
Copy Markdown
Member

Summary

In parse_object_literal_element, the shorthand-property path built value eagerly and cloned the IdentifierReference so it could be reused for the CoverInitializedName ({ foo = bar }) case. In the common { foo } path the clone was always wasted.

Build value after peeking =, and allocate a fresh IdentifierReference in each branch. One .clone() removed per shorthand property.

…d property

Build `value` after handling `=`, and allocate a fresh `IdentifierReference`
in each branch instead of cloning. Saves one clone per shorthand property.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@github-actions github-actions Bot added A-parser Area - Parser C-performance Category - Solution not expected to change functional behavior, only performance labels Apr 16, 2026
@codspeed-hq

codspeed-hq Bot commented Apr 16, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 48 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing perf/parser-shorthand-ident-clone (7606f47) with main (7dbbb99)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Boshen
Boshen merged commit ddb1bf8 into main Apr 17, 2026
35 checks passed
@Boshen
Boshen deleted the perf/parser-shorthand-ident-clone branch April 17, 2026 00:47
camc314 added a commit that referenced this pull request Apr 20, 2026
### 🐛 Bug Fixes

- 48967e8 isolated_declarations: Drop required type check for private
parameter properties on private constructors (#21515) (Dunqing)
- 91e5bde transformer/typescript: Preserve computed-key static block
when class has an empty constructor (#21562) (Dunqing)
- 50e9d26 mangler: Assign correct slot to shadowed function-expression
names (#21535) (Dunqing)
- 065ce47 isolated_declarations: Collect types from private accessors
for paired inference (#21516) (Dunqing)
- 00fc136 codegen: Preserve coverage comments before object properties
(#21312) (bab)
- d676e0c minifier: Mark LHS of `??=` as read when converting from `==
null &&` (#21546) (Gunnlaugur Thor Briem)

### ⚡ Performance

- e45efc5 parser: Reduce `try_parse` usage in favour of `lookahead`
(#21532) (Boshen)
- ddb1bf8 parser: Avoid redundant `IdentifierReference` clone in
shorthand property (#21511) (Boshen)
- be2b392 allocator: Store pointers directly in `Arena` (#21483)
(overlookmotel)

Co-authored-by: Boshen <[email protected]>
Co-authored-by: Cameron <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant