perf(parser): reduce try_parse usage in favour of lookahead#21532
perf(parser): reduce try_parse usage in favour of lookahead#21532graphite-app[bot] merged 1 commit intomainfrom
try_parse usage in favour of lookahead#21532Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c03be268fb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Merging this PR will not alter performance
Comparing Footnotes
|
camchenry
left a comment
There was a problem hiding this comment.
makes sense to me I think, the number of allocations reduced looks great
Merge activity
|
## Summary `try_parse` rewinds on failure, but it keeps AST nodes the failed branch allocated into the arena until end of parse, uses the more expensive `checkpoint_with_error_recovery` (which full-clones the errors vec), and forces the lexer to re-scan the same bytes on the committed reparse. Where the discriminator is just a token peek, `lookahead` (or a direct `peek_token`) is strictly cheaper. Conformance unchanged: no snapshot drift on Test262, Babel, or TypeScript suites. part of #21540 🤖 Generated with [Claude Code](https://claude.com/claude-code)
4e23c2f to
e45efc5
Compare
### 🐛 Bug Fixes - 48967e8 isolated_declarations: Drop required type check for private parameter properties on private constructors (#21515) (Dunqing) - 91e5bde transformer/typescript: Preserve computed-key static block when class has an empty constructor (#21562) (Dunqing) - 50e9d26 mangler: Assign correct slot to shadowed function-expression names (#21535) (Dunqing) - 065ce47 isolated_declarations: Collect types from private accessors for paired inference (#21516) (Dunqing) - 00fc136 codegen: Preserve coverage comments before object properties (#21312) (bab) - d676e0c minifier: Mark LHS of `??=` as read when converting from `== null &&` (#21546) (Gunnlaugur Thor Briem) ### ⚡ Performance - e45efc5 parser: Reduce `try_parse` usage in favour of `lookahead` (#21532) (Boshen) - ddb1bf8 parser: Avoid redundant `IdentifierReference` clone in shorthand property (#21511) (Boshen) - be2b392 allocator: Store pointers directly in `Arena` (#21483) (overlookmotel) Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com> Co-authored-by: Cameron <cameron.clark@hey.com>
Summary
try_parserewinds on failure, but it keeps AST nodes the failed branchallocated into the arena until end of parse, uses the more expensive
checkpoint_with_error_recovery(which full-clones the errors vec), andforces the lexer to re-scan the same bytes on the committed reparse.
Where the discriminator is just a token peek,
lookahead(or a directpeek_token) is strictly cheaper.Conformance unchanged: no snapshot drift on Test262, Babel, or TypeScript
suites.
part of #21540
🤖 Generated with Claude Code