perf(estree/tokens): do not JSON-encode JSX identifiers#19812
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR extends the identifier token serialization optimization from #19744 to JSX identifiers. Instead of JSON-encoding JSX identifier tokens character-by-character, it uses the optimized EstreeIdentToken serializer which assumes the identifier name is JSON-safe and manually assembles the JSON with minimal bounds checking.
Changes:
- Added
emit_jsx_identifiermethod that usesserialize_ident_tokenfor JSX identifiers - Replaced all
emit_token_atcalls for JSX identifiers withemit_jsx_identifier
Merge activity
|
Same as #19744, but for JSX identifiers. Serialize them using the same optimized `EstreeIdentToken` serializer added in this PR. No effect on ESTree tokens benchmark, but the fixture file doesn't contain JSX. I imagine it'd be a sizeable improvement for JSX files.
c0cea8e to
5016d92
Compare
6d2668e to
b378f4a
Compare
…ns (#19814) After #19744, #19813, #19812, and #19796, all tokens which require special handling or can contain `value`s which are possibly not JSON-safe are handled separately. So everything remaining (keywords, punctuators etc) are JSON-safe and can be serialized via the optimized serializer introduced for identifiers in #19744. To reflect that `EstreeIdentToken` now handles a lot more than identifiers, rename it to `EstreeSafeToken`, and rename `EstreeToken` to `EstreeUnsafeToken`. Large positive perf impact. +24% on ESTree tokens benchmark.

Same as #19744, but for JSX identifiers. Serialize them using the same optimized
EstreeIdentTokenserializer added in this PR.No effect on ESTree tokens benchmark, but the fixture file doesn't contain JSX. I imagine it'd be a sizeable improvement for JSX files.