Skip to content

Commit a5b25a2

Browse files
committed
Create subslice as that leads to a smaller code size.
1 parent 2d9f0e2 commit a5b25a2

File tree

1 file changed

+4
-3
lines changed
  • compiler/rustc_parse/src/lexer

1 file changed

+4
-3
lines changed

compiler/rustc_parse/src/lexer/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,15 @@ impl<'a> StringReader<'a> {
153153
match core::slice::memchr::memchr(0xE2, &bytes) {
154154
Some(idx) => {
155155
// bytes are valid UTF-8 -> E2 must be followed by two bytes
156-
match bytes[idx + 1] {
156+
let ch = &bytes[idx..idx + 3];
157+
match ch[1] {
157158
0x80 => {
158-
if (0xAA..=0xAE).contains(&bytes[idx + 2]) {
159+
if (0xAA..=0xAE).contains(&ch[2]) {
159160
break true;
160161
}
161162
}
162163
0x81 => {
163-
if (0xA6..=0xA9).contains(&bytes[idx + 2]) {
164+
if (0xA6..=0xA9).contains(&ch[2]) {
164165
break true;
165166
}
166167
}

0 commit comments

Comments
 (0)