Skip to content

Commit 2ea0410

Browse files
committed
str::is_char_boundary - slight optimization
1 parent 49920bc commit 2ea0410

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/core/src/str/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@ impl str {
195195
// 0 and len are always ok.
196196
// Test for 0 explicitly so that it can optimize out the check
197197
// easily and skip reading string data for that case.
198-
if index == 0 || index == self.len() {
198+
if index == 0 {
199199
return true;
200200
}
201201
match self.as_bytes().get(index) {
202-
None => false,
202+
None => index == self.len(),
203203
// This is bit magic equivalent to: b < 128 || b >= 192
204204
Some(&b) => (b as i8) >= -0x40,
205205
}

0 commit comments

Comments
 (0)