perf(estree): use CodeBuffer::print_indent#19727
Merged
graphite-app[bot] merged 1 commit intomainfrom Feb 26, 2026
Merged
Conversation
This was referenced Feb 25, 2026
This was referenced Feb 25, 2026
f6e952a to
8f936b9
Compare
Idents from AST for identifier tokensCodeBuffer::print_indent
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the ESTree JSON serialization to use the optimized CodeBuffer::print_indent method instead of manually iterating over spaces with an unsafe method. The change improves performance for pretty-printing JSON output (used in conformance tests) and removes unsafe code.
Changes:
- Configure
CodeBufferwith indent settings (2 spaces per level) at initialization - Change
PrettyFormatterto track indent levels instead of total spaces - Replace unsafe
print_bytes_iter_uncheckedwith optimizedprint_indentmethod
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/mod.rs | Add IndentChar import and initialize CodeBuffer with 2-space indent configuration |
| crates/oxc_estree/src/serialize/formatter.rs | Remove std::iter import, change indent tracking from spaces to levels, use print_indent method |
8f936b9 to
da9445a
Compare
This was referenced Feb 26, 2026
This was referenced Feb 26, 2026
Contributor
Merge activity
|
`ESTree::serialize` use `CodeBuffer::indent` to print indentation, instead of using unsafe method `CodeBuffer::print_bytes_iter_unchecked`. `indent` method is more optimized, and this removes some `unsafe`. This only applies to pretty-printing JSON, as indentation is not used in compact JSON. Therefore it doesn't affect our production code, but it should speed up conformance tests a bit.
da9445a to
845da35
Compare
This was referenced Feb 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ESTree::serializeuseCodeBuffer::indentto print indentation, instead of using unsafe methodCodeBuffer::print_bytes_iter_unchecked.indentmethod is more optimized, and this removes someunsafe.This only applies to pretty-printing JSON, as indentation is not used in compact JSON. Therefore it doesn't affect our production code, but it should speed up conformance tests a bit.