summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrik Sverdrup <bluss@users.noreply.github.com>2016-08-24 21:41:23 +0200
committerAlex Crichton <alex@alexcrichton.com>2016-09-12 16:58:28 -0700
commitf79ab4fca8bb25e1fdbeeef6ad98a3820ce43733 (patch)
tree0957d7ea1ae84251a41204f0476da40a1d04434d
parent3ca48fe73e4ce50f36839fb6e4486dcb3fc6c203 (diff)
downloadrust-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.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);
             }