about summary refs log tree commit diff
path: root/src/libcore/str
diff options
context:
space:
mode:
authorTristan Storch <tstorch@math.uni-bielefeld.de>2015-01-13 17:45:04 +0100
committerTristan Storch <tstorch@math.uni-bielefeld.de>2015-01-14 16:34:45 +0100
commit5b6d0245b8055f176c606604ac6cc0f50ef79b45 (patch)
treed66665e777256a6354c40f1d017e9023dfc1f88d /src/libcore/str
parente94a9f033eb79b3b4fb037722366644650e8e16c (diff)
downloadrust-5b6d0245b8055f176c606604ac6cc0f50ef79b45.tar.gz
rust-5b6d0245b8055f176c606604ac6cc0f50ef79b45.zip
Small Readability Update
Diffstat (limited to 'src/libcore/str')
-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 94ee9b7dcf6..cf8a96f4396 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()