This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +11
-2
lines changed Expand file tree Collapse file tree 4 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -4064,6 +4064,7 @@ name = "rustc_lexer"
40644064version = " 0.0.0"
40654065dependencies = [
40664066 " expect-test" ,
4067+ " memchr" ,
40674068 " unicode-properties" ,
40684069 " unicode-xid" ,
40694070]
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ Rust lexer used by rustc. No stability guarantees are provided.
1414
1515# Note that this crate purposefully does not depend on other rustc crates
1616[dependencies ]
17+ memchr = " 2.7.4"
1718unicode-xid = " 0.2.0"
1819
1920[dependencies .unicode-properties ]
Original file line number Diff line number Diff line change @@ -103,4 +103,11 @@ impl<'a> Cursor<'a> {
103103 self . bump ( ) ;
104104 }
105105 }
106+
107+ pub ( crate ) fn eat_until ( & mut self , byte : u8 ) {
108+ self . chars = match memchr:: memchr ( byte, self . as_str ( ) . as_bytes ( ) ) {
109+ Some ( index) => self . as_str ( ) [ index..] . chars ( ) ,
110+ None => "" . chars ( ) ,
111+ }
112+ }
106113}
Original file line number Diff line number Diff line change @@ -483,7 +483,7 @@ impl Cursor<'_> {
483483 _ => None ,
484484 } ;
485485
486- self . eat_while ( |c| c != '\n' ) ;
486+ self . eat_until ( b '\n') ;
487487 LineComment { doc_style }
488488 }
489489
@@ -888,7 +888,7 @@ impl Cursor<'_> {
888888 // Skip the string contents and on each '#' character met, check if this is
889889 // a raw string termination.
890890 loop {
891- self . eat_while ( |c| c != '"' ) ;
891+ self . eat_until ( b '"') ;
892892
893893 if self . is_eof ( ) {
894894 return Err ( RawStrError :: NoTerminator {
You can’t perform that action at this time.
0 commit comments