]> git.lizzy.rs Git - rust.git/commitdiff
clippy::perf fixes
authorMatthias Krüger <matthias.krueger@famsik.de>
Sun, 1 Aug 2021 19:26:29 +0000 (21:26 +0200)
committerMatthias Krüger <matthias.krueger@famsik.de>
Sun, 1 Aug 2021 21:44:54 +0000 (23:44 +0200)
compiler/rustc_mir/src/transform/coverage/debug.rs
compiler/rustc_typeck/src/check/method/prelude2021.rs
compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs

index 6fd7d29d7779712860d0c0be87da30b943d36e37..464079656f9fb0d8357406aaed4551045066999e 100644 (file)
@@ -369,10 +369,10 @@ fn format_operand(&self, operand: ExpressionOperandId) -> String {
                     }
                     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())
     }
 }
 
index 9e3292d7821a9e7c121be24e8adc4244b8e35786..b5bc9d3599acbf78435a0aac31394514e38acaa0 100644 (file)
@@ -265,7 +265,7 @@ pub(super) fn lint_fully_qualified_call_from_2018(
                 // 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 {
index f039790eca118a5dd1d0b4afd9145b55198ff7b2..1c36335be8167d9a003033d6eba4df2741991c12 100644 (file)
@@ -222,8 +222,8 @@ struct ConnectedRegion {
                                 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();
 
                                 let mut region = connected_regions.remove(&id_to_set).unwrap();
                                 region.idents.extend_from_slice(&idents_to_add);
@@ -266,8 +266,8 @@ struct ConnectedRegion {
                     // 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() {