about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorUlrik Sverdrup <bluss@users.noreply.github.com>2016-08-24 21:41:23 +0200
committerUlrik Sverdrup <bluss@users.noreply.github.com>2016-08-24 21:41:23 +0200
commit8295c5056da0be355c86b29d1d4eed469920e73c (patch)
treea670e10e751bdb087cde48c5a1f0746c7cb0dbd5 /src/libstd
parentd1ecee96bfb7fb52b67358302c524a8c0193dc23 (diff)
downloadrust-8295c5056da0be355c86b29d1d4eed469920e73c.tar.gz
rust-8295c5056da0be355c86b29d1d4eed469920e73c.zip
memrchr: Use a conditional instead of subtracting a complicated min
This makes the critical calculation easier to understand.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/memchr.rs2
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);
             }