Skip to content

clippy::perf fixes #87686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_mir/src/transform/coverage/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,10 @@ impl DebugCounters {
}
return format!("({})", self.format_counter_kind(counter_kind));
}
return self.format_counter_kind(counter_kind).to_string();
return self.format_counter_kind(counter_kind);
}
}
format!("#{}", operand.index().to_string())
format!("#{}", operand.index())
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/method/prelude2021.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Get the number of generics the self type has (if an Adt) unless we can determine that
// the user has written the self type with generics already which we (naively) do by looking
// for a "<" in `self_ty_name`.
Adt(def, _) if !self_ty_name.contains("<") => self.tcx.generics_of(def.did).count(),
Adt(def, _) if !self_ty_name.contains('<') => self.tcx.generics_of(def.did).count(),
_ => 0,
};
let self_ty_generics = if self_ty_generics_count > 0 {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ impl ItemLikeVisitor<'v> for InherentOverlapChecker<'tcx> {
let id_to_set = *ids.iter().min().unwrap();

// Sort the id list so that the algorithm is deterministic
let mut ids = ids.into_iter().collect::<SmallVec<[_; 8]>>();
ids.sort();
let mut ids = ids.into_iter().collect::<SmallVec<[usize; 8]>>();
ids.sort_unstable();
Comment on lines +225 to +226
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this (and lower) sort's need to be stable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are sorting primitives (usizes) here, so it does not matter if we have 1, 1, 1 or 1, 1, 1 :)


let mut region = connected_regions.remove(&id_to_set).unwrap();
region.idents.extend_from_slice(&idents_to_add);
Expand Down Expand Up @@ -266,8 +266,8 @@ impl ItemLikeVisitor<'v> for InherentOverlapChecker<'tcx> {
// for each pair of impl blocks in the same connected region.
for (_id, region) in connected_regions.into_iter() {
let mut impl_blocks =
region.impl_blocks.into_iter().collect::<SmallVec<[_; 8]>>();
impl_blocks.sort();
region.impl_blocks.into_iter().collect::<SmallVec<[usize; 8]>>();
impl_blocks.sort_unstable();
for (i, &impl1_items_idx) in impl_blocks.iter().enumerate() {
let &(&impl1_def_id, impl_items1) = &impls_items[impl1_items_idx];
for &impl2_items_idx in impl_blocks[(i + 1)..].iter() {
Expand Down