about summary refs log tree commit diff
diff options
context:
space:
mode:
authorStjepan Glavina <stjepang@gmail.com>2017-02-08 16:01:32 +0100
committerStjepan Glavina <stjepang@gmail.com>2017-02-08 16:01:32 +0100
commitececbb26875c7aa2d9a6b20af5280a700dba11c8 (patch)
tree115461f191a7b99257bf1258d00abd3536e27062
parent3bd6e46687b0d7ea347b6bb860bb1c35dfe2e7cc (diff)
downloadrust-ececbb26875c7aa2d9a6b20af5280a700dba11c8.tar.gz
rust-ececbb26875c7aa2d9a6b20af5280a700dba11c8.zip
Simplify by calling SliceOrd::compare
-rw-r--r--src/libcore/slice.rs16
1 files changed, 1 insertions, 15 deletions
diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs
index 18244cec7c7..7d052c218fe 100644
--- a/src/libcore/slice.rs
+++ b/src/libcore/slice.rs
@@ -2294,21 +2294,7 @@ impl<A> SlicePartialOrd<A> for [A]
     where A: Ord
 {
     default fn partial_compare(&self, other: &[A]) -> Option<Ordering> {
-        let l = cmp::min(self.len(), other.len());
-
-        // Slice to the loop iteration range to enable bound check
-        // elimination in the compiler
-        let lhs = &self[..l];
-        let rhs = &other[..l];
-
-        for i in 0..l {
-            match lhs[i].cmp(&rhs[i]) {
-                Ordering::Equal => (),
-                non_eq => return Some(non_eq),
-            }
-        }
-
-        self.len().partial_cmp(&other.len())
+        Some(SliceOrd::compare(self, other))
     }
 }