Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 258115e

Browse files
hkBstfolkertdev
andcommittedFeb 20, 2025
fewer branches for skip_whitespace
Co-authored-by: Folkert de Vries <flokkievids@gmail.com>
1 parent d4feb08 commit 258115e

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed
 

‎compiler/rustc_lexer/src/unescape.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -392,15 +392,14 @@ where
392392
let mut contains_nl = false;
393393

394394
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,
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)
Failed to load comments.