diff options
| author | ljedrz <ljedrz@gmail.com> | 2018-07-25 10:36:57 +0200 |
|---|---|---|
| committer | ljedrz <ljedrz@gmail.com> | 2018-07-25 12:13:02 +0200 |
| commit | f653bf4fba40c6415b6f580c30fbcfe2e82cce62 (patch) | |
| tree | abcbdc4a509699c1c3ba0c2e53c43898767fc69b /src/librustc_driver | |
| parent | 13985724033467ab86da9136c43fe242092b294e (diff) | |
| download | rust-f653bf4fba40c6415b6f580c30fbcfe2e82cce62.tar.gz rust-f653bf4fba40c6415b6f580c30fbcfe2e82cce62.zip | |
Improve readability in a few sorts
Diffstat (limited to 'src/librustc_driver')
| -rw-r--r-- | src/librustc_driver/lib.rs | 5 | ||||
| -rw-r--r-- | src/librustc_driver/profile/trace.rs | 5 |
2 files changed, 3 insertions, 7 deletions
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 2100ceea228..000025c49a6 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -1229,10 +1229,7 @@ Available lint options: fn sort_lint_groups(lints: Vec<(&'static str, Vec<lint::LintId>, bool)>) -> Vec<(&'static str, Vec<lint::LintId>)> { let mut lints: Vec<_> = lints.into_iter().map(|(x, y, _)| (x, y)).collect(); - lints.sort_by(|&(x, _): &(&'static str, Vec<lint::LintId>), - &(y, _): &(&'static str, Vec<lint::LintId>)| { - x.cmp(y) - }); + lints.sort_by_key(|ref l| l.0); lints } diff --git a/src/librustc_driver/profile/trace.rs b/src/librustc_driver/profile/trace.rs index 5f10c56e8e2..4aaf5eb47f6 100644 --- a/src/librustc_driver/profile/trace.rs +++ b/src/librustc_driver/profile/trace.rs @@ -202,14 +202,13 @@ fn compute_counts_rec(counts: &mut HashMap<String,QueryMetric>, traces: &Vec<Rec pub fn write_counts(count_file: &mut File, counts: &mut HashMap<String,QueryMetric>) { use rustc::util::common::duration_to_secs_str; - use std::cmp::Ordering; + use std::cmp::Reverse; let mut data = vec![]; for (ref cons, ref qm) in counts.iter() { data.push((cons.clone(), qm.count.clone(), qm.dur_total.clone(), qm.dur_self.clone())); }; - data.sort_by(|&(_,_,_,self1),&(_,_,_,self2)| - if self1 > self2 { Ordering::Less } else { Ordering::Greater } ); + data.sort_by_key(|&k| Reverse(k.3)); for (cons, count, dur_total, dur_self) in data { write!(count_file, "{}, {}, {}, {}\n", cons, count, |
