fix(es/parser): Don't call bump_bytes in the continue_if of byte_search!#11328
fix(es/parser): Don't call bump_bytes in the continue_if of byte_search!#11328kdy1 merged 4 commits intoswc-project:mainfrom
bump_bytes in the continue_if of byte_search!#11328Conversation
🦋 Changeset detectedLatest commit: ea61d97 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue in the byte_search! macro usage where bump_bytes was being called within the continue_if block, breaking the invariant that the lexer position should only be bumped at the end of the macro. The fix refactors the block comment parsing to use offset-based position tracking and defer the final bump until after the search completes.
Key Changes
- Added documentation to the
byte_search!macro explaining the pointer-based search approach and warning about not changing lexer position incontinue_if - Removed local
had_line_breakvariable and replaced with direct calls tomark_had_line_break() - Replaced manual
bump_bytescalls incontinue_ifwith offset increments, deferring position updates to the macro's end
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| crates/swc_ecma_parser/src/lexer/search.rs | Added documentation for the byte_search! macro explaining its behavior and usage constraints |
| crates/swc_ecma_parser/src/lexer/mod.rs | Refactored skip_block_comment to use offset-based tracking instead of calling bump_bytes in continue_if, eliminating the local had_line_break variable |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
CodSpeed Performance ReportMerging #11328 will not alter performanceComparing Summary
|
Binary Sizes
Commit: 1411811 |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
Description:
In #11323, we only records the
posas an offset related the current remaining string and bumps the lexer at the end ofbyte_search!to reduce the calls tobump_bytes. However, ifbump_bytesis manually called in thecontinue_if, the invariant is broken.