refactor(transformer/object_rest_spread): simplify code#24011
Conversation
Merging this PR will improve performance by 5.12%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | formatter[types.ts] |
13.7 ms | 12.7 ms | +7.63% |
| ⚡ | Simulation | formatter[handle-comments.js] |
2.8 ms | 2.7 ms | +5.62% |
| ⚡ | Simulation | formatter[App.tsx] |
50.8 ms | 48.1 ms | +5.57% |
| ⚡ | Simulation | formatter[Search.tsx] |
1.7 ms | 1.6 ms | +5.17% |
| ⚡ | Simulation | formatter[core.js] |
1.6 ms | 1.5 ms | +5.12% |
| ⚡ | Simulation | formatter[index.tsx] |
3.8 ms | 3.6 ms | +4.9% |
| ⚡ | Simulation | formatter[errors.ts] |
572.1 µs | 547.5 µs | +4.48% |
| ⚡ | Simulation | formatter[next.ts] |
2.3 ms | 2.2 ms | +4.03% |
| ⚡ | Simulation | formatter[RadixUIAdoptionSection.jsx] |
412 µs | 397.6 µs | +3.63% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing om/07-01-refactor_transformer_object_rest_spread_simplify_code (9238bc3) with om/06-27-perf_transformer_nullish_coalescing_move_cold_path_into_separate_function (0ece13e)2
Footnotes
-
19 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. ↩
-
No successful run was found on
om/06-27-perf_transformer_nullish_coalescing_move_cold_path_into_separate_function(2cc4353) during the generation of this report, so b0de19e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
There was a problem hiding this comment.
Pull request overview
Refactors the ES2018 object rest/spread transformer to slightly simplify statement-to-block wrapping by hoisting the statement span computation, relying on Statement::span() being uniformly available.
Changes:
- Hoist
let span = stmt.span();out of the empty-statement conditional. - Simplify construction of the block body statements vector by removing the prior
(span, stmts)tuple.
Merge activity
|
Small simplification. `Statement::span` is branchless (as every variant of `Statement` has `span: Span` field in same position), so can hoist getting the statement's `Span` out of the `if ... else` block, and it should have no effect on perf.
2cc4353 to
e6d48e1
Compare
9238bc3 to
0b14f1a
Compare
Small simplification. `Statement::span` is branchless (as every variant of `Statement` has `span: Span` field in same position), so can hoist getting the statement's `Span` out of the `if ... else` block, and it should have no effect on perf.

Small simplification.
Statement::spanis branchless (as every variant ofStatementhasspan: Spanfield in same position), so can hoist getting the statement'sSpanout of theif ... elseblock, and it should have no effect on perf.