Skip to content

Commit 7089355

Browse files
hkBstfolkertdev
andauthored
fewer branches for skip_whitespace
Co-authored-by: Folkert de Vries <[email protected]>
1 parent d4feb08 commit 7089355

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

compiler/rustc_lexer/src/unescape.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -391,16 +391,15 @@ where
391391
let mut spaces = 0;
392392
let mut contains_nl = false;
393393

394-
for byte in chars.as_str().bytes() {
395-
match byte {
396-
b' ' | b'\t' | b'\r' => {
397-
spaces += 1;
398-
}
399-
b'\n' => {
400-
spaces += 1;
401-
contains_nl = true;
402-
}
403-
_ => break,
394+
for &byte in chars.as_str().bytes() {
395+
let is_space = matches!(byte, b' ' | b'\t' | b'\r' | b'\n');
396+
let is_newline = byte == b'\n';
397+
398+
spaces += is_space as usize;
399+
contains_nl |= is_newline;
400+
401+
if !is_space {
402+
break;
404403
}
405404
}
406405
*chars = chars.as_str()[spaces..].chars();

0 commit comments

Comments
 (0)