]> git.lizzy.rs Git - rust.git/commitdiff
librustc_lexer: Simplify "double_quoted_string" method
authorIgor Aleksanov <popzxc@yandex.ru>
Sun, 3 Nov 2019 09:55:05 +0000 (12:55 +0300)
committerIgor Aleksanov <popzxc@yandex.ru>
Sun, 3 Nov 2019 09:55:05 +0000 (12:55 +0300)
src/librustc_lexer/src/lib.rs

index 2edf3bd78efb96e576188e66e02ad4721de72d69..6653ddc3072260ca6687ed6b5007ceacd3a820da 100644 (file)
@@ -580,20 +580,20 @@ fn single_quoted_string(&mut self) -> bool {
     /// if string is terminated.
     fn double_quoted_string(&mut self) -> bool {
         debug_assert!(self.prev() == '"');
-        loop {
-            match self.nth_char(0) {
+        while let Some(c) = self.bump() {
+            match c {
                 '"' => {
-                    self.bump();
                     return true;
                 }
-                EOF_CHAR if self.is_eof() => return false,
-                '\\' if self.nth_char(1) == '\\' || self.nth_char(1) == '"' => {
+                '\\' if self.first() == '\\' || self.first() == '"' => {
+                    // Bump again to skip escaped character.
                     self.bump();
                 }
                 _ => (),
             }
-            self.bump();
         }
+        // End of file reached.
+        false
     }
 
     /// Eats the double-quoted string and returns a tuple of