mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-15 20:45:45 +03:00
Rollup merge of #55821 - ljedrz:cached_key_sorts, r=michaelwoerister
Use sort_by_cached_key when the key function is not trivial/free I'm not 100% sure about `def_path_hash` (everything it does is inlined) but it seems like a good idea at least for the rest, as they are cloning.
This commit is contained in:
@@ -1573,7 +1573,7 @@ fn check_uses_for_lifetimes_defined_by_scope(&mut self) {
|
||||
.collect();
|
||||
|
||||
// ensure that we issue lints in a repeatable order
|
||||
def_ids.sort_by_key(|&def_id| self.tcx.def_path_hash(def_id));
|
||||
def_ids.sort_by_cached_key(|&def_id| self.tcx.def_path_hash(def_id));
|
||||
|
||||
for def_id in def_ids {
|
||||
debug!(
|
||||
|
||||
@@ -409,7 +409,7 @@ fn object_ty_for_trait(self, trait_def_id: DefId, lifetime: ty::Region<'tcx>) ->
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// existential predicates need to be in a specific order
|
||||
associated_types.sort_by_key(|item| self.def_path_hash(item.def_id));
|
||||
associated_types.sort_by_cached_key(|item| self.def_path_hash(item.def_id));
|
||||
|
||||
let projection_predicates = associated_types.into_iter().map(|item| {
|
||||
ty::ExistentialPredicate::Projection(ty::ExistentialProjection {
|
||||
|
||||
@@ -985,7 +985,7 @@ fn collect_and_partition_mono_items<'a, 'tcx>(
|
||||
output.push_str(" @@");
|
||||
let mut empty = Vec::new();
|
||||
let cgus = item_to_cgus.get_mut(i).unwrap_or(&mut empty);
|
||||
cgus.as_mut_slice().sort_by_key(|&(ref name, _)| name.clone());
|
||||
cgus.as_mut_slice().sort_by_cached_key(|&(ref name, _)| name.clone());
|
||||
cgus.dedup();
|
||||
for &(ref cgu_name, (linkage, _)) in cgus.iter() {
|
||||
output.push_str(" ");
|
||||
|
||||
Reference in New Issue
Block a user