about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2016-10-03 18:57:18 +1100
committerNicholas Nethercote <nnethercote@mozilla.com>2016-10-03 18:57:18 +1100
commit49960ad2503eb050e02c6c428111a59d5bc16ba3 (patch)
tree169061bdff32d2ff2d5766240996967ffab8a274 /src/libsyntax/parse
parent144af3e97aa30feba3d36a98ac04c0f1b2bc0bea (diff)
downloadrust-49960ad2503eb050e02c6c428111a59d5bc16ba3.tar.gz
rust-49960ad2503eb050e02c6c428111a59d5bc16ba3.zip
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.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/lexer/mod.rs4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs
index 6c0e2425d37..1b326aeb8ea 100644
--- a/src/libsyntax/parse/lexer/mod.rs
+++ b/src/libsyntax/parse/lexer/mod.rs
@@ -417,11 +417,9 @@ impl<'a> StringReader<'a> {
         self.last_pos = self.pos;
         let current_byte_offset = self.byte_offset(self.pos).to_usize();
         if current_byte_offset < self.source_text.len() {
-            assert!(self.curr.is_some());
             let last_char = self.curr.unwrap();
             let ch = char_at(&self.source_text, current_byte_offset);
-            let next = current_byte_offset + ch.len_utf8();
-            let byte_offset_diff = next - current_byte_offset;
+            let byte_offset_diff = ch.len_utf8();
             self.pos = self.pos + Pos::from_usize(byte_offset_diff);
             self.curr = Some(ch);
             self.col = self.col + CharPos(1);