Skip to content

perf(parser): remove string search from parsing JSX element name#23713

Merged
graphite-app[bot] merged 1 commit into
mainfrom
om/06-21-perf_parser_remove_string_search_from_parsing_jsx_element_name
Jun 22, 2026
Merged

perf(parser): remove string search from parsing JSX element name#23713
graphite-app[bot] merged 1 commit into
mainfrom
om/06-21-perf_parser_remove_string_search_from_parsing_jsx_element_name

Conversation

@overlookmotel

@overlookmotel overlookmotel commented Jun 22, 2026

Copy link
Copy Markdown
Member

Optimization to parsing JSX.

When parsing JSX element names parse_jsx_element_name has to determine if the identifier:

  1. starts with a lowercase letter, and
  2. contains a -.

The 2nd check is relatively expensive - string search.

Avoid the search by making the lexer feed this information (which it already has) to the parser. This reduces the check in the parser to just !contains_dash.

(came across this while working on #23712)

Copy link
Copy Markdown
Member Author

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 changes, fast-track this PR to the front of the merge queue

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 A-parser Area - Parser label Jun 22, 2026
@overlookmotel overlookmotel marked this pull request as ready for review June 22, 2026 13:02
Copilot AI review requested due to automatic review settings June 22, 2026 13:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Optimizes JSX parsing in oxc_parser by avoiding per-identifier string searches for '-' when classifying JSX element names, instead reusing information already available during lexing.

Changes:

  • Changed parse_jsx_identifier to return (JSXIdentifier, contains_dash) so callers can avoid name.contains('-').
  • Updated JSX element-name classification and member-expression parsing to use contains_dash.
  • Updated continue_lex_jsx_identifier to return a bool indicating whether retokenization occurred.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
crates/oxc_parser/src/jsx/mod.rs Propagates a lexer-derived contains_dash flag through JSX identifier parsing to eliminate name.contains('-') searches.
crates/oxc_parser/src/cursor.rs Makes continue_lex_jsx_identifier return a boolean so the parser can cheaply detect hyphenated JSX identifiers.

Comment thread crates/oxc_parser/src/cursor.rs
@codspeed-hq

codspeed-hq Bot commented Jun 22, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 9 skipped benchmarks1


Comparing om/06-21-perf_parser_remove_string_search_from_parsing_jsx_element_name (0338837) with main (cf5e47e)

Open in CodSpeed

Footnotes

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

@overlookmotel

overlookmotel commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

Not sure who to ask to review, so I've asked you both @Dunqing and @camc314. Whoever gets to it first...

@camc314 camc314 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚀

@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Jun 22, 2026

camc314 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Merge activity

)

Optimization to parsing JSX.

When parsing JSX element names `parse_jsx_element_name` has to determine if the identifier:

1. starts with a lowercase letter, and
2. contains a `-`.

The 2nd check is relatively expensive - string search.

Avoid the search by making the lexer feed this information (which it already has) to the parser. This reduces the check in the parser to just `!contains_dash`.

(came across this while working #23712)
@graphite-app graphite-app Bot force-pushed the om/06-21-perf_parser_remove_string_search_from_parsing_jsx_element_name branch from 0338837 to 10b96c6 Compare June 22, 2026 16:48
@graphite-app graphite-app Bot merged commit 10b96c6 into main Jun 22, 2026
30 checks passed
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label Jun 22, 2026
@graphite-app graphite-app Bot deleted the om/06-21-perf_parser_remove_string_search_from_parsing_jsx_element_name branch June 22, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants