Skip to content

feat(estree): add IS_COMPACT const to Formatter trait#19787

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/02-26-feat_estree_add_is_compact_const_to_formatter_trait
Feb 27, 2026
Merged

feat(estree): add IS_COMPACT const to Formatter trait#19787
graphite-app[bot] merged 1 commit intomainfrom
om/02-26-feat_estree_add_is_compact_const_to_formatter_trait

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Feb 26, 2026

Add IS_COMPACT const to Formatter and Serializer traits. In conjunction with #19773, callers can manually construct JSON themselves in the correct format for the serializer (compact or pretty-printed).

This is used in #19744 to net a +9% perf gain in ESTree token serialization.

Copy link
Member Author

overlookmotel commented Feb 26, 2026


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.

@github-actions github-actions bot added the C-enhancement Category - New feature or request label Feb 26, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 26, 2026

Merging this PR will not alter performance

✅ 52 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/02-26-feat_estree_add_is_compact_const_to_formatter_trait (8b9f2ae) with om/02-26-feat_estree_expose_buffer_and_formatter_of_serializers (6f29d1c)2

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.

  2. No successful run was found on om/02-26-feat_estree_expose_buffer_and_formatter_of_serializers (aea71cc) during the generation of this report, so d1f4b1c was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

This was referenced Feb 26, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an IS_COMPACT associated constant to both the Formatter and Serializer traits, enabling callers to determine at compile-time whether a serializer produces compact or pretty-printed JSON. This change supports performance optimizations in #19744 (which achieves a +9% perf gain in ESTree token serialization) by allowing callers to manually construct JSON in the correct format when working with the low-level APIs exposed in #19773.

Changes:

  • Add IS_COMPACT const to Formatter trait with implementations in CompactFormatter and PrettyFormatter
  • Add IS_COMPACT const to Serializer trait with a default value that delegates to the formatter

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/oxc_estree/src/serialize/formatter.rs Adds IS_COMPACT const to Formatter trait and implements it as true for CompactFormatter and false for PrettyFormatter
crates/oxc_estree/src/serialize/mod.rs Adds IS_COMPACT const to Serializer trait with a default value that delegates to Self::Formatter::IS_COMPACT

@overlookmotel overlookmotel force-pushed the om/02-26-feat_estree_expose_buffer_and_formatter_of_serializers branch from 6f29d1c to aea71cc Compare February 26, 2026 23:41
@overlookmotel overlookmotel force-pushed the om/02-26-feat_estree_add_is_compact_const_to_formatter_trait branch from d55eb11 to 8b9f2ae Compare February 26, 2026 23:41
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Feb 26, 2026
@graphite-app graphite-app bot changed the base branch from om/02-26-feat_estree_expose_buffer_and_formatter_of_serializers to graphite-base/19787 February 26, 2026 23:54
@graphite-app graphite-app bot force-pushed the graphite-base/19787 branch from aea71cc to e2a1b79 Compare February 27, 2026 00:01
@graphite-app graphite-app bot force-pushed the om/02-26-feat_estree_add_is_compact_const_to_formatter_trait branch from 8b9f2ae to 0bf18b1 Compare February 27, 2026 00:01
@graphite-app graphite-app bot changed the base branch from graphite-base/19787 to main February 27, 2026 00:01
@graphite-app graphite-app bot force-pushed the om/02-26-feat_estree_add_is_compact_const_to_formatter_trait branch from 0bf18b1 to 207b91f Compare February 27, 2026 00:01
@graphite-app
Copy link
Contributor

graphite-app bot commented Feb 27, 2026

Merge activity

Add `IS_COMPACT` const to `Formatter` and `Serializer` traits. In conjunction with #19773, callers can manually construct JSON themselves in the correct format for the serializer (compact or pretty-printed).

This is used in #19744 to net a +9% perf gain in ESTree token serialization.
@graphite-app graphite-app bot force-pushed the om/02-26-feat_estree_add_is_compact_const_to_formatter_trait branch from 207b91f to b25228a Compare February 27, 2026 00:10
@graphite-app graphite-app bot merged commit b25228a into main Feb 27, 2026
21 checks passed
@graphite-app graphite-app bot deleted the om/02-26-feat_estree_add_is_compact_const_to_formatter_trait branch February 27, 2026 00:17
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter-plugins Area - Linter JS plugins A-parser Area - Parser C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants