Skip to content

Commit 6a5c948

Browse files
committed
Rollup merge of rust-lang#21100 - tstorch:small_readability_update, r=alexcrichton
Why not use what is there?
2 parents 4419fa3 + 5b6d024 commit 6a5c948

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/libcore/str/mod.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -678,18 +678,15 @@ struct TwoWaySearcher {
678678
*/
679679
impl TwoWaySearcher {
680680
fn new(needle: &[u8]) -> TwoWaySearcher {
681-
let (crit_pos1, period1) = TwoWaySearcher::maximal_suffix(needle, false);
682-
let (crit_pos2, period2) = TwoWaySearcher::maximal_suffix(needle, true);
683-
684-
let crit_pos;
685-
let period;
686-
if crit_pos1 > crit_pos2 {
687-
crit_pos = crit_pos1;
688-
period = period1;
689-
} else {
690-
crit_pos = crit_pos2;
691-
period = period2;
692-
}
681+
let (crit_pos_false, period_false) = TwoWaySearcher::maximal_suffix(needle, false);
682+
let (crit_pos_true, period_true) = TwoWaySearcher::maximal_suffix(needle, true);
683+
684+
let (crit_pos, period) =
685+
if crit_pos_false > crit_pos_true {
686+
(crit_pos_false, period_false)
687+
} else {
688+
(crit_pos_true, period_true)
689+
};
693690

694691
// This isn't in the original algorithm, as far as I'm aware.
695692
let byteset = needle.iter()

0 commit comments

Comments
 (0)