Use cursor offset for lexer checkpoint#11734
Merged
dhruvmanila merged 1 commit intomainfrom Jun 4, 2024
Merged
Conversation
dhruvmanila
commented
Jun 4, 2024
Comment on lines
+1373
to
+1376
| let mut cursor = Cursor::new(self.source); | ||
| // We preserve the previous char using this method. | ||
| cursor.skip_bytes(cursor_offset.to_usize()); | ||
|
|
Member
Author
There was a problem hiding this comment.
We could use Cursor::new(self.source[cursor_offset.to_usize()..] but that would always set the previous character to EOF.
Contributor
|
carljm
added a commit
that referenced
this pull request
Jun 4, 2024
* main: CI: add job to run tests under minimum supported rust version (msrv) (#11737) Lexer should consider BOM for the start offset (#11732) Use cursor offset for lexer checkpoint (#11734) red-knot: Change `resolve_global_symbol` to take `Module` as an argument (#11723) red-knot: Use `parse_unchecked` to get all parse errors (#11725) Respect per-file ignores for blanket and redirected noqa rules (#11728) [`pygrep_hooks`] Check blanket ignores via file-level pragmas (`PGH004`) (#11540)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR updates the lexer checkpoint to store the cursor offset instead of cloning the cursor itself. This reduces the size of
LexerCheckpointfrom 136 to 112 bytes and also removes the need for lifetime.Test Plan
cargo insta test