about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarosl LEE <github@barosl.com>2015-01-21 02:16:48 +0900
committerBarosl LEE <github@barosl.com>2015-01-21 02:16:48 +0900
commit6a5c948a00c010b32ca02caf8254d72ea73aab45 (patch)
tree8da175a5204467e8df9aaacd2264bf90ff70daab
parent4419fa39c21da965f4f618ab915a53cf419b318e (diff)
parent5b6d0245b8055f176c606604ac6cc0f50ef79b45 (diff)
downloadrust-6a5c948a00c010b32ca02caf8254d72ea73aab45.tar.gz
rust-6a5c948a00c010b32ca02caf8254d72ea73aab45.zip
Rollup merge of #21100 - tstorch:small_readability_update, r=alexcrichton
Why not use what is there?
-rw-r--r--src/libcore/str/mod.rs21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs
index d9cf6dc086d..6a542b2c458 100644
--- a/src/libcore/str/mod.rs
+++ b/src/libcore/str/mod.rs
@@ -678,18 +678,15 @@ struct TwoWaySearcher {
 */
 impl TwoWaySearcher {
     fn new(needle: &[u8]) -> TwoWaySearcher {
-        let (crit_pos1, period1) = TwoWaySearcher::maximal_suffix(needle, false);
-        let (crit_pos2, period2) = TwoWaySearcher::maximal_suffix(needle, true);
-
-        let crit_pos;
-        let period;
-        if crit_pos1 > crit_pos2 {
-            crit_pos = crit_pos1;
-            period = period1;
-        } else {
-            crit_pos = crit_pos2;
-            period = period2;
-        }
+        let (crit_pos_false, period_false) = TwoWaySearcher::maximal_suffix(needle, false);
+        let (crit_pos_true, period_true) = TwoWaySearcher::maximal_suffix(needle, true);
+
+        let (crit_pos, period) =
+            if crit_pos_false > crit_pos_true {
+                (crit_pos_false, period_false)
+            } else {
+                (crit_pos_true, period_true)
+            };
 
         // This isn't in the original algorithm, as far as I'm aware.
         let byteset = needle.iter()