diff options
| author | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2016-08-24 21:41:23 +0200 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2016-09-12 16:58:28 -0700 |
| commit | f79ab4fca8bb25e1fdbeeef6ad98a3820ce43733 (patch) | |
| tree | 0957d7ea1ae84251a41204f0476da40a1d04434d | |
| parent | 3ca48fe73e4ce50f36839fb6e4486dcb3fc6c203 (diff) | |
| download | rust-f79ab4fca8bb25e1fdbeeef6ad98a3820ce43733.tar.gz rust-f79ab4fca8bb25e1fdbeeef6ad98a3820ce43733.zip | |
memrchr: Use a conditional instead of subtracting a complicated min
This makes the critical calculation easier to understand.
| -rw-r--r-- | src/libstd/memchr.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libstd/memchr.rs b/src/libstd/memchr.rs index 89b77a7d661..03f55f7ad61 100644 --- a/src/libstd/memchr.rs +++ b/src/libstd/memchr.rs @@ -209,7 +209,7 @@ mod fallback { let end_align = (ptr as usize + len) & (usize_bytes - 1); let mut offset; if end_align > 0 { - offset = len - cmp::min(end_align, len); + offset = if end_align >= len { 0 } else { len - end_align }; if let Some(index) = text[offset..].iter().rposition(|elt| *elt == x) { return Some(offset + index); } |
