diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2016-04-11 10:31:28 -0400 |
|---|---|---|
| committer | Steve Klabnik <steve@steveklabnik.com> | 2016-04-11 10:31:28 -0400 |
| commit | c5842837b86abc720446055118bf714dabe30730 (patch) | |
| tree | 0892aabe980c8ec49802e175bb5842da13bc81db | |
| parent | 7ba7e02b5ed025d1271d3cae0c475a526510b321 (diff) | |
| parent | b2db97347bc4373deea24eb7b7c6ecffb117fd8c (diff) | |
| download | rust-c5842837b86abc720446055118bf714dabe30730.tar.gz rust-c5842837b86abc720446055118bf714dabe30730.zip | |
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
| -rw-r--r-- | src/libcore/str/mod.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 305546df5be..f1be10da872 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1940,7 +1940,8 @@ impl StrExt for str { if index == 0 || index == self.len() { return true; } match self.as_bytes().get(index) { None => false, - Some(&b) => b < 128 || b >= 192, + // This is bit magic equivalent to: b < 128 || b >= 192 + Some(&b) => (b as i8) >= -0x40, } } |
