perf(transformer/object-rest-spread): collect Vec<SymbolId over Vec<BindingIdentifier>#22418
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Vec<SymbolId over Vec<Ident>Vec<SymbolId over Vec< BindingIdentifier >
Vec<SymbolId over Vec< BindingIdentifier >Vec<SymbolId over Vec<BindingIdentifier>
There was a problem hiding this comment.
Pull request overview
This PR optimizes the ES2018 object rest/spread transformer by avoiding Ident cloning when collecting bindings in for (...; ...; ...) destructuring patterns, collecting SymbolIds directly instead.
Changes:
- Replaced
bound_names(... push(ident.clone()))withBindingPattern::get_symbol_ids()to collect bound identifiers asVec<SymbolId>. - Simplified the subsequent binding-move loop to iterate symbol IDs directly when moving bindings from the for-init scope into the loop body scope.
Merging this PR will not alter performance
Comparing Footnotes
|
Merge activity
|
…c<BindingIdentifier>` (#22418) `SymbolId` is copy, hence cheaper to clone into the `Vec` rather than cloning the whole `BindingIdentifier` (and only using the `symbol_id` property of it.
dce1dad to
8b2f4f9
Compare
### 🚀 Features - bc91a17 codegen: Expose `Codegen::with_source_type` method (#22432) (camc314) ### 🐛 Bug Fixes - 5ac7e79 minifier: Drop unused-var-init pure IIFEs and preserve annotation for downstream (#22349) (Dunqing) - 4ab57eb allocator: Fixed-size allocators use `VirtualAlloc` on Windows (#22124) (overlookmotel) - 66d77eb allocator: Fix segfault on Linux MUSL with fixed-size allocators (#22388) (overlookmotel) - b8fbc1f transformer/object-rest-spread: Correct scope id when moving bindings (#22419) (camc314) - 18edc2c codegen: Keep `Object.defineProperty` property name as plain string in minify (#22400) (Dunqing) - dda33de transformer/explicit-resource-management: Align lexical binding scopes (#22320) (camc314) - 8e79de8 transformer: Preserve for-await statement bodies (#22361) (camc314) - 0cba210 transformer/class: Replace `new.target` in static blocks (#22360) (camc314) - 67ab1c9 transformer/es2018/for-await: Hoist for-await generated bindings (#22355) (camc314) - c3ceb4a transformer/object-rest-spread: Use hoisted scope for `for-of` temp refs (#22347) (camc314) ### ⚡ Performance - 73a9043 allocator/bitset: Avoid temp heap `String` allocation (#22403) (camc314) - 8b2f4f9 transformer/object-rest-spread: Collect `Vec<SymbolId` over `Vec<BindingIdentifier>` (#22418) (camc314) - 83679ea parser: Split TriviaBuilder::handle_token hot/cold paths (#22415) (Boshen) - 2c7d781 codegen: Inline identifier-name accessors (#22411) (Boshen) - 618bc76 diagnostics: Inline `OxcDiagnosticInner` to avoid heap allocation (#22406) (Boshen) - 0b4e158 parser: Reserve cap `2` for sequence expressions vec (#22374) (camc314) - 5f3bdd0 codegen: Add `#[inline]` to `code`, `code_len` (#22373) (camc314) Co-authored-by: overlookmotel <557937+overlookmotel@users.noreply.github.com>

SymbolIdis copy, hence cheaper to clone into theVecrather than cloning the wholeBindingIdentifier(and only using thesymbol_idproperty of it.