From b90936449b161f4aee5ff81bbb4906bf5a27f181 Mon Sep 17 00:00:00 2001 From: Vadzim Dambrouski Date: Tue, 28 Mar 2017 17:43:01 +0300 Subject: [PATCH] libcore: sort_unstable: remove unnecessary loop. `other` is guaranteed to be less than `2 * len`. --- src/libcore/slice/sort.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libcore/slice/sort.rs b/src/libcore/slice/sort.rs index 3612ee65bca0d..7065fdb79fc40 100644 --- a/src/libcore/slice/sort.rs +++ b/src/libcore/slice/sort.rs @@ -527,7 +527,9 @@ fn break_patterns(v: &mut [T]) { // we first take it modulo a power of two, and then decrease by `len` until it fits // into the range `[0, len - 1]`. let mut other = gen_usize() & (modulus - 1); - while other >= len { + + // `other` is guaranteed to be less than `2 * len`. + if other >= len { other -= len; }