Skip to content

Commit

Permalink
Use eat_char2 wherever possible
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Aug 29, 2023
1 parent ca4c0cd commit b367eac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
12 changes: 5 additions & 7 deletions crates/ruff_python_parser/src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,7 @@ impl<'source> Lexer<'source> {
if is_raw_string {
flags |= FStringContextFlags::RAW;
}
if self.cursor.first() == quote && self.cursor.second() == quote {
self.cursor.bump();
self.cursor.bump();
if self.cursor.eat_char2(quote, quote) {
flags |= FStringContextFlags::TRIPLE;
};

Expand Down Expand Up @@ -645,8 +643,8 @@ impl<'source> Lexer<'source> {
self.cursor.bump();
normalized
.push_str(&self.source[TextRange::new(last_offset, self.offset())]);
self.cursor.bump();
last_offset = self.offset(); // Skip the second `{`
self.cursor.bump(); // Skip the second `{`
last_offset = self.offset();
} else {
break;
}
Expand All @@ -659,8 +657,8 @@ impl<'source> Lexer<'source> {
self.cursor.bump();
normalized
.push_str(&self.source[TextRange::new(last_offset, self.offset())]);
self.cursor.bump();
last_offset = self.offset(); // Skip the second `}`
self.cursor.bump(); // Skip the second `}`
last_offset = self.offset();
} else {
break;
}
Expand Down
1 change: 0 additions & 1 deletion crates/ruff_python_parser/src/lexer/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ impl<'a> Cursor<'a> {
}
}

#[cfg(feature = "pep-701")]
pub(super) fn eat_char2(&mut self, c1: char, c2: char) -> bool {
let mut chars = self.chars.clone();
if chars.next() == Some(c1) && chars.next() == Some(c2) {
Expand Down

0 comments on commit b367eac

Please sign in to comment.