Skip to content

refactor(transformer/object_rest_spread): simplify code#24011

Merged
graphite-app[bot] merged 1 commit into
mainfrom
om/07-01-refactor_transformer_object_rest_spread_simplify_code
Jul 2, 2026
Merged

refactor(transformer/object_rest_spread): simplify code#24011
graphite-app[bot] merged 1 commit into
mainfrom
om/07-01-refactor_transformer_object_rest_spread_simplify_code

Conversation

@overlookmotel

@overlookmotel overlookmotel commented Jul 1, 2026

Copy link
Copy Markdown
Member

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.

overlookmotel commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of 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.

@github-actions github-actions Bot added the A-transformer Area - Transformer / Transpiler label Jul 1, 2026
@overlookmotel
overlookmotel marked this pull request as ready for review July 1, 2026 15:12
@overlookmotel
overlookmotel requested a review from Dunqing as a code owner July 1, 2026 15:12
Copilot AI review requested due to automatic review settings July 1, 2026 15:12
@codspeed-hq

codspeed-hq Bot commented Jul 1, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 5.12%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 9 improved benchmarks
✅ 43 untouched benchmarks
⏩ 19 skipped benchmarks1

Performance Changes

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

Open in CodSpeed

Footnotes

  1. 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.

  2. 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Dunqing Dunqing added the 0-merge Merge with Graphite Merge Queue label Jul 2, 2026

Dunqing commented Jul 2, 2026

Copy link
Copy Markdown
Member

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.
@graphite-app
graphite-app Bot force-pushed the om/06-27-perf_transformer_nullish_coalescing_move_cold_path_into_separate_function branch from 2cc4353 to e6d48e1 Compare July 2, 2026 01:32
@graphite-app
graphite-app Bot force-pushed the om/07-01-refactor_transformer_object_rest_spread_simplify_code branch from 9238bc3 to 0b14f1a Compare July 2, 2026 01:33
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label Jul 2, 2026
Base automatically changed from om/06-27-perf_transformer_nullish_coalescing_move_cold_path_into_separate_function to main July 2, 2026 01:37
@graphite-app
graphite-app Bot merged commit 0b14f1a into main Jul 2, 2026
31 checks passed
@graphite-app
graphite-app Bot deleted the om/07-01-refactor_transformer_object_rest_spread_simplify_code branch July 2, 2026 01:38
camc314 pushed a commit that referenced this pull request Jul 3, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-transformer Area - Transformer / Transpiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants