-
-
Notifications
You must be signed in to change notification settings - Fork 721
perf(parser): add separate token kinds for BigInt literals #14405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds separate token kinds for BigInt literals to eliminate string suffix checking during parsing. The lexer now directly communicates BigInt vs Number types through the token kind, improving performance by replacing string operations with enum comparisons.
Key changes:
- Added four new
Kindenum variants for BigInt literals (DecimalBigInt,BinaryBigInt,OctalBigInt,HexBigInt) - Updated lexer logic to return BigInt-specific kinds when 'n' suffix is detected
- Modified parser to match on BigInt kinds instead of performing string suffix checks
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/oxc_parser/src/lexer/kind.rs | Added new BigInt token kinds and updated is_number() method |
| crates/oxc_parser/src/lexer/numeric.rs | Modified lexer to return BigInt kinds when 'n' suffix is consumed |
| crates/oxc_parser/src/js/expression.rs | Updated parser to match BigInt kinds directly instead of string checking |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
CodSpeed Performance ReportMerging #14405 will not alter performanceComparing Summary
Footnotes |
Merge activity
|
## Summary
Add separate token kinds (`DecimalBigInt`, `BinaryBigInt`, `OctalBigInt`, `HexBigInt`) to eliminate the `ends_with('n')` string check when parsing BigInt literals.
531e558 to
791c72a
Compare
Summary
Add separate token kinds (
DecimalBigInt,BinaryBigInt,OctalBigInt,HexBigInt) to eliminate theends_with('n')string check when parsing BigInt literals.