mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-15 08:23:26 +00:00
Rollup merge of #32862 - raphlinus:master, r=bluss
Bit-magic for faster is_char_boundary The asm generated for b < 128 || b >= 192 is not ideal, as it computes both sub-inequalities. This patch replaces it with bit magic. Fixes #32471
This commit is contained in:
commit
c5842837b8
@ -1940,7 +1940,8 @@ impl StrExt for str {
|
|||||||
if index == 0 || index == self.len() { return true; }
|
if index == 0 || index == self.len() { return true; }
|
||||||
match self.as_bytes().get(index) {
|
match self.as_bytes().get(index) {
|
||||||
None => false,
|
None => false,
|
||||||
Some(&b) => b < 128 || b >= 192,
|
// This is bit magic equivalent to: b < 128 || b >= 192
|
||||||
|
Some(&b) => (b as i8) >= -0x40,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user