Skip to content

perf(formatter): optimize formatting of JSX element/fragment with a single child#16631

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-09-perf_formatter_optimize_formatting_of_jsx_element_fragment_with_a_single_child
Dec 9, 2025
Merged

perf(formatter): optimize formatting of JSX element/fragment with a single child#16631
graphite-app[bot] merged 1 commit intomainfrom
12-09-perf_formatter_optimize_formatting_of_jsx_element_fragment_with_a_single_child

Conversation

@Dunqing
Copy link
Copy Markdown
Member

@Dunqing Dunqing commented Dec 9, 2025

Add FormatSingleChild for optimizing JSX elements/fragments with a single meaningful child.

When there is only a single child, we do not need to write the child into a temporary buffer and then take it when formatting. Instead, we can directly write the child into the root buffer.

Also, this can avoid calling costly best_fitting! formatting in some situations.

@github-actions github-actions bot added A-formatter Area - Formatter C-performance Category - Solution not expected to change functional behavior, only performance labels Dec 9, 2025
Copy link
Copy Markdown
Member Author

Dunqing commented Dec 9, 2025


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 hot fixes, skip the queue and merge this PR next

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.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Dec 9, 2025

CodSpeed Performance Report

Merging #16631 will not alter performance

Comparing 12-09-perf_formatter_optimize_formatting_of_jsx_element_fragment_with_a_single_child (bc98c23) with 12-09-perf_formatter_do_not_write_elements_to_the_flat_buffer_if_the_layout_is_multline (b3581c8)

Summary

✅ 38 untouched
⏩ 7 skipped1

Footnotes

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

@Dunqing Dunqing force-pushed the 12-09-perf_formatter_do_not_write_elements_to_the_flat_buffer_if_the_layout_is_multline branch from 8d58f68 to c17b3d4 Compare December 9, 2025 07:45
@Dunqing Dunqing force-pushed the 12-09-perf_formatter_optimize_formatting_of_jsx_element_fragment_with_a_single_child branch 2 times, most recently from 53474e3 to e739576 Compare December 9, 2025 08:01
@Dunqing Dunqing force-pushed the 12-09-perf_formatter_do_not_write_elements_to_the_flat_buffer_if_the_layout_is_multline branch from c17b3d4 to 02172b8 Compare December 9, 2025 08:01
@Dunqing Dunqing force-pushed the 12-09-perf_formatter_optimize_formatting_of_jsx_element_fragment_with_a_single_child branch from e739576 to 64adcd2 Compare December 9, 2025 08:17
@Dunqing Dunqing force-pushed the 12-09-perf_formatter_do_not_write_elements_to_the_flat_buffer_if_the_layout_is_multline branch from 02172b8 to b3581c8 Compare December 9, 2025 08:17
@Dunqing Dunqing marked this pull request as ready for review December 9, 2025 08:25
@Dunqing Dunqing requested a review from leaysgur December 9, 2025 08:28
@Dunqing Dunqing force-pushed the 12-09-perf_formatter_optimize_formatting_of_jsx_element_fragment_with_a_single_child branch 2 times, most recently from 6515f47 to bc98c23 Compare December 9, 2025 08:51
@leaysgur leaysgur added the 0-merge Merge with Graphite Merge Queue label Dec 9, 2025
Copy link
Copy Markdown
Member

leaysgur commented Dec 9, 2025

Merge activity

…ingle child (#16631)

Add `FormatSingleChild` for optimizing JSX elements/fragments with a single meaningful child.

When there is only a single child, we do not need to write the child into a temporary buffer and then take it when formatting. Instead, we can directly write the child into the root buffer.

Also, this can avoid calling costly `best_fitting!` formatting in some situations.
@graphite-app graphite-app bot force-pushed the 12-09-perf_formatter_do_not_write_elements_to_the_flat_buffer_if_the_layout_is_multline branch from b3581c8 to 4843475 Compare December 9, 2025 09:06
@graphite-app graphite-app bot force-pushed the 12-09-perf_formatter_optimize_formatting_of_jsx_element_fragment_with_a_single_child branch from bc98c23 to c7db70b Compare December 9, 2025 09:07
Base automatically changed from 12-09-perf_formatter_do_not_write_elements_to_the_flat_buffer_if_the_layout_is_multline to main December 9, 2025 09:12
@graphite-app graphite-app bot merged commit c7db70b into main Dec 9, 2025
21 checks passed
@graphite-app graphite-app bot deleted the 12-09-perf_formatter_optimize_formatting_of_jsx_element_fragment_with_a_single_child branch December 9, 2025 09:13
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 9, 2025
Copilot AI pushed a commit that referenced this pull request Dec 10, 2025
…ingle child (#16631)

Add `FormatSingleChild` for optimizing JSX elements/fragments with a single meaningful child.

When there is only a single child, we do not need to write the child into a temporary buffer and then take it when formatting. Instead, we can directly write the child into the root buffer.

Also, this can avoid calling costly `best_fitting!` formatting in some situations.
taearls pushed a commit to taearls/oxc that referenced this pull request Dec 11, 2025
…ingle child (oxc-project#16631)

Add `FormatSingleChild` for optimizing JSX elements/fragments with a single meaningful child.

When there is only a single child, we do not need to write the child into a temporary buffer and then take it when formatting. Instead, we can directly write the child into the root buffer.

Also, this can avoid calling costly `best_fitting!` formatting in some situations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-formatter Area - Formatter 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.

2 participants