aboutsummaryrefslogtreecommitdiffstats
path: root/components/util
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2015-01-22 13:25:07 +0100
committerMs2ger <ms2ger@gmail.com>2015-01-22 14:49:25 +0100
commit524966e3af8fbc871005cef460dc86c379a36034 (patch)
tree7975a1eb769f4bb430a886423666bc4ad67f9ddd /components/util
parent59bca2962c19f653eec835fc54caf1a3eadcb906 (diff)
downloadservo-524966e3af8fbc871005cef460dc86c379a36034.tar.gz
servo-524966e3af8fbc871005cef460dc86c379a36034.zip
Use std::cmp::Ordering explicitly.
Diffstat (limited to 'components/util')
-rw-r--r--components/util/sort.rs10
-rw-r--r--components/util/time.rs5
-rw-r--r--components/util/vec.rs8
3 files changed, 13 insertions, 10 deletions
diff --git a/components/util/sort.rs b/components/util/sort.rs
index 73a244f713f..d31948cb0e8 100644
--- a/components/util/sort.rs
+++ b/components/util/sort.rs
@@ -4,6 +4,8 @@
//! In-place sorting.
+use std::cmp::Ordering;
+
fn quicksort_helper<T>(arr: &mut [T], left: int, right: int, compare: fn(&T, &T) -> Ordering) {
if right <= left {
return
@@ -17,11 +19,11 @@ fn quicksort_helper<T>(arr: &mut [T], left: int, right: int, compare: fn(&T, &T)
let v: *mut T = &mut arr[right as uint];
loop {
i += 1;
- while compare(&arr[i as uint], &*v) == Less {
+ while compare(&arr[i as uint], &*v) == Ordering::Less {
i += 1
}
j -= 1;
- while compare(&*v, &arr[j as uint]) == Less {
+ while compare(&*v, &arr[j as uint]) == Ordering::Less {
if j == left {
break
}
@@ -31,11 +33,11 @@ fn quicksort_helper<T>(arr: &mut [T], left: int, right: int, compare: fn(&T, &T)
break
}
arr.swap(i as uint, j as uint);
- if compare(&arr[i as uint], &*v) == Equal {
+ if compare(&arr[i as uint], &*v) == Ordering::Equal {
p += 1;
arr.swap(p as uint, i as uint)
}
- if compare(&*v, &arr[j as uint]) == Equal {
+ if compare(&*v, &arr[j as uint]) == Ordering::Equal {
q -= 1;
arr.swap(j as uint, q as uint)
}
diff --git a/components/util/time.rs b/components/util/time.rs
index abe35633e92..a47f3a98c8c 100644
--- a/components/util/time.rs
+++ b/components/util/time.rs
@@ -6,6 +6,7 @@
use collections::TreeMap;
use std::borrow::ToOwned;
+use std::cmp::Ordering;
use std::comm::{Sender, channel, Receiver};
use std::f64;
use std::io::timer::sleep;
@@ -228,9 +229,9 @@ impl TimeProfiler {
for (&(ref category, ref meta), ref mut data) in self.buckets.iter_mut() {
data.sort_by(|a, b| {
if a < b {
- Less
+ Ordering::Less
} else {
- Greater
+ Ordering::Greater
}
});
let data_len = data.len();
diff --git a/components/util/vec.rs b/components/util/vec.rs
index b9a67b6760b..c34b76a9794 100644
--- a/components/util/vec.rs
+++ b/components/util/vec.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-use std::cmp::{PartialOrd, PartialEq};
+use std::cmp::{PartialOrd, PartialEq, Ordering};
#[cfg(test)]
use std::fmt::Show;
@@ -47,9 +47,9 @@ impl<'a, T> FullBinarySearchMethods<T> for &'a [T] {
let midv = &self[mid];
match cmp.compare(key, midv) {
- Greater => low = (mid as int) + 1,
- Less => high = (mid as int) - 1,
- Equal => return Some(mid),
+ Ordering::Greater => low = (mid as int) + 1,
+ Ordering::Less => high = (mid as int) - 1,
+ Ordering::Equal => return Some(mid),
}
}
return None;