Skip to content

Commit 49960ad

Browse files
committed
Streamline StringReader::bump.
First, assert! is redundant w.r.t. the unwrap() immediately afterwards. Second, `byte_offset_diff` is effectively computed as `current_byte_offset + ch.len_utf8() - current_byte_offset` (with `next` as an intermediate) which is silly and can be simplified.
1 parent 144af3e commit 49960ad

File tree

1 file changed

+1
-3
lines changed
  • src/libsyntax/parse/lexer

1 file changed

+1
-3
lines changed

src/libsyntax/parse/lexer/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -417,11 +417,9 @@ impl<'a> StringReader<'a> {
417417
self.last_pos = self.pos;
418418
let current_byte_offset = self.byte_offset(self.pos).to_usize();
419419
if current_byte_offset < self.source_text.len() {
420-
assert!(self.curr.is_some());
421420
let last_char = self.curr.unwrap();
422421
let ch = char_at(&self.source_text, current_byte_offset);
423-
let next = current_byte_offset + ch.len_utf8();
424-
let byte_offset_diff = next - current_byte_offset;
422+
let byte_offset_diff = ch.len_utf8();
425423
self.pos = self.pos + Pos::from_usize(byte_offset_diff);
426424
self.curr = Some(ch);
427425
self.col = self.col + CharPos(1);

0 commit comments

Comments
 (0)