Skip to content

refactor(estree/tokens): replace stored token when re-lexing#19698

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/02-21-refactor_estree_tokens_replace_stored_token_when_re-lexing
Feb 25, 2026
Merged

refactor(estree/tokens): replace stored token when re-lexing#19698
graphite-app[bot] merged 1 commit intomainfrom
om/02-21-refactor_estree_tokens_replace_stored_token_when_re-lexing

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented Feb 25, 2026

Previously the ESTree tokens serializer had a special case to skip a << token which has same start as preceding < token. Instead, solve this problem at source - prevent this duplicate token from being in the Vec<Token> in the first place, by modifying the parser.

This is important because we want to move to sending tokens to JS via raw transfer, and we need the Vec<Token> to have the right number of tokens in it to start with, so we can do lazy deserialization and just get a token at a specific index. This breaks down if there are extra tokens that need to be skipped.

The logic around this in parser is quite labyrinthine, so add lengthy comments explaining it.

This change also simplifies the main loop in ESTree serializer, so has side effect of +1% on estree_tokens benchmark. Conversely, it doesn't affect the parser_tokens benchmark perf, because the path in parser which got more complex is not commonly taken.

@github-actions github-actions bot added A-parser Area - Parser C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Feb 25, 2026
This was referenced Feb 25, 2026
Copy link
Copy Markdown
Member Author

overlookmotel commented Feb 25, 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.

@graphite-app graphite-app bot changed the base branch from om/02-24-perf_parser_remove_branches_from_finish_next_inner_ to graphite-base/19698 February 25, 2026 00:08
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Feb 25, 2026

Merging this PR will not alter performance

✅ 52 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/02-21-refactor_estree_tokens_replace_stored_token_when_re-lexing (79a366f) with main (14b0fb7)

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.

@graphite-app graphite-app bot force-pushed the graphite-base/19698 branch from 1eac4b3 to 7233548 Compare February 25, 2026 00:15
This was referenced Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-linter Area - Linter A-linter-plugins Area - Linter JS plugins A-parser Area - Parser C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants