feat(estree): add IS_COMPACT const to Formatter trait#19787
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
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_COMPACTconst toFormattertrait with implementations inCompactFormatterandPrettyFormatter - Add
IS_COMPACTconst toSerializertrait 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 |
6f29d1c to
aea71cc
Compare
d55eb11 to
8b9f2ae
Compare
aea71cc to
e2a1b79
Compare
8b9f2ae to
0bf18b1
Compare
0bf18b1 to
207b91f
Compare
Merge activity
|
207b91f to
b25228a
Compare

Add
IS_COMPACTconst toFormatterandSerializertraits. 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.