Use cmp::Reverse instead of subtraction
This commit is contained in:
parent
1aa61526a7
commit
2cc52f08b3
2 changed files with 5 additions and 4 deletions
|
|
@ -112,11 +112,11 @@ use rustc::ty::{self, TyCtxt, InstanceDef};
|
|||
use rustc::ty::item_path::characteristic_def_id_of_type;
|
||||
use rustc::util::nodemap::{FxHashMap, FxHashSet};
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::cmp;
|
||||
use syntax::ast::NodeId;
|
||||
use syntax::symbol::{Symbol, InternedString};
|
||||
use rustc::mir::mono::MonoItem;
|
||||
use monomorphize::item::{MonoItemExt, InstantiationMode};
|
||||
use core::usize;
|
||||
|
||||
pub use rustc::mir::mono::CodegenUnit;
|
||||
|
||||
|
|
@ -509,7 +509,7 @@ fn merge_codegen_units<'tcx>(initial_partitioning: &mut PreInliningPartitioning<
|
|||
// Merge the two smallest codegen units until the target size is reached.
|
||||
while codegen_units.len() > target_cgu_count {
|
||||
// Sort small cgus to the back
|
||||
codegen_units.sort_by_cached_key(|cgu| usize::MAX - cgu.size_estimate());
|
||||
codegen_units.sort_by_cached_key(|cgu| cmp::Reverse(cgu.size_estimate()));
|
||||
let mut smallest = codegen_units.pop().unwrap();
|
||||
let second_smallest = codegen_units.last_mut().unwrap();
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,8 @@ use std::ffi::CString;
|
|||
use std::str;
|
||||
use std::sync::Arc;
|
||||
use std::time::{Instant, Duration};
|
||||
use std::{i32, usize};
|
||||
use std::i32;
|
||||
use std::cmp;
|
||||
use std::sync::mpsc;
|
||||
use syntax_pos::Span;
|
||||
use syntax_pos::symbol::InternedString;
|
||||
|
|
@ -830,7 +831,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
// a bit more efficiently.
|
||||
let codegen_units = {
|
||||
let mut codegen_units = codegen_units;
|
||||
codegen_units.sort_by_cached_key(|cgu| usize::MAX - cgu.size_estimate());
|
||||
codegen_units.sort_by_cached_key(|cgu| cmp::Reverse(cgu.size_estimate()));
|
||||
codegen_units
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue