diff options
| author | bors <bors@rust-lang.org> | 2015-01-20 23:03:09 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-01-20 23:03:09 +0000 |
| commit | 29bd9a06efd2f8c8a7b1102e2203cc0e6ae2dcba (patch) | |
| tree | 98824cc18b1c65ff09f383438d79ad2d0a0e2ea8 /src/libcore/str | |
| parent | 583c5c589ed02e5b6b14a576e35e0ce68988d949 (diff) | |
| parent | 631896dc1996d239a532b0ce02d5fe886660149e (diff) | |
| download | rust-29bd9a06efd2f8c8a7b1102e2203cc0e6ae2dcba.tar.gz rust-29bd9a06efd2f8c8a7b1102e2203cc0e6ae2dcba.zip | |
Auto merge of #21439 - alexcrichton:rollup, r=alexcrichton
Continuation of https://github.com/rust-lang/rust/pull/21428
Diffstat (limited to 'src/libcore/str')
| -rw-r--r-- | src/libcore/str/mod.rs | 21 |
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() |
