diff options
| author | Soveu <marx.tomasz@gmail.com> | 2021-04-30 16:13:00 +0200 |
|---|---|---|
| committer | Soveu <marx.tomasz@gmail.com> | 2021-04-30 16:13:00 +0200 |
| commit | 2ea0410f090ae06d18f5535e62e888e49a4f21a7 (patch) | |
| tree | 9c72784c05961ee762e78a4613d6842310402218 | |
| parent | 49920bc581743d6edb9f82fbff4cbafebc212619 (diff) | |
| download | rust-2ea0410f090ae06d18f5535e62e888e49a4f21a7.tar.gz rust-2ea0410f090ae06d18f5535e62e888e49a4f21a7.zip | |
str::is_char_boundary - slight optimization
| -rw-r--r-- | library/core/src/str/mod.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 95dd54976b2..e7970bf5c8f 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -195,11 +195,11 @@ impl str { // 0 and len are always ok. // Test for 0 explicitly so that it can optimize out the check // easily and skip reading string data for that case. - if index == 0 || index == self.len() { + if index == 0 { return true; } match self.as_bytes().get(index) { - None => false, + None => index == self.len(), // This is bit magic equivalent to: b < 128 || b >= 192 Some(&b) => (b as i8) >= -0x40, } |
