From 3af6291effa78880e8318425d7327577eb265b66 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 31 May 2018 10:52:29 +1000 Subject: [PATCH 1/2] Tweak identifer lexing. By calling `bump()` after getting the first char, to avoid a redundant `ident_continue()` test on it. --- src/libsyntax/parse/lexer/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index c39eb1594b28b..02f76fa56e402 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -516,6 +516,7 @@ impl<'a> StringReader<'a> { return None; } let start = self.pos; + self.bump(); while ident_continue(self.ch) { self.bump(); } @@ -1155,6 +1156,7 @@ impl<'a> StringReader<'a> { } let start = self.pos; + self.bump(); while ident_continue(self.ch) { self.bump(); } From 5adba8e9d9cbd5f662f91984146b2341460dbd99 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 31 May 2018 13:37:44 +1000 Subject: [PATCH 2/2] Avoid an unnecessary `match` when lexing "<-". --- src/libsyntax/parse/lexer/mod.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 02f76fa56e402..c3ad9eec0827f 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1302,11 +1302,7 @@ impl<'a> StringReader<'a> { } '-' => { self.bump(); - match self.ch.unwrap_or('\x00') { - _ => { - Ok(token::LArrow) - } - } + Ok(token::LArrow) } _ => { Ok(token::Lt)