Skip to content

Commit a25ce40

Browse files
authored
Rollup merge of #68818 - matthiaskrgr:misc_perf, r=Mark-Simulacrum
fix couple of perf related clippy warnings librustc: don't clone a type that is copy librustc_incremental: use faster vector initialization librustc_typeck: don't clone a type that is copy librustdoc: don't create a vector where a slice will do
2 parents 3fe4c0d + fe1314d commit a25ce40

File tree

4 files changed

+5
-15
lines changed

4 files changed

+5
-15
lines changed

src/librustc/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,7 @@ pub trait ToPredicate<'tcx> {
13471347
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<TraitRef<'tcx>> {
13481348
fn to_predicate(&self) -> Predicate<'tcx> {
13491349
ty::Predicate::Trait(
1350-
ty::Binder::dummy(ty::TraitPredicate { trait_ref: self.value.clone() }),
1350+
ty::Binder::dummy(ty::TraitPredicate { trait_ref: self.value }),
13511351
self.constness,
13521352
)
13531353
}

src/librustc_incremental/persist/file_format.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ pub fn read_file(
9090
let mut rustc_version_str_len = [0u8; 1];
9191
file.read_exact(&mut rustc_version_str_len)?;
9292
let rustc_version_str_len = rustc_version_str_len[0] as usize;
93-
let mut buffer = Vec::with_capacity(rustc_version_str_len);
94-
buffer.resize(rustc_version_str_len, 0);
93+
let mut buffer = vec![0; rustc_version_str_len];
9594
file.read_exact(&mut buffer)?;
9695

9796
if buffer != rustc_version().as_bytes() {

src/librustc_typeck/astconv.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1438,10 +1438,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
14381438

14391439
// Expand trait aliases recursively and check that only one regular (non-auto) trait
14401440
// is used and no 'maybe' bounds are used.
1441-
let expanded_traits = traits::expand_trait_aliases(
1442-
tcx,
1443-
bounds.trait_bounds.iter().map(|&(a, b, _)| (a.clone(), b)),
1444-
);
1441+
let expanded_traits =
1442+
traits::expand_trait_aliases(tcx, bounds.trait_bounds.iter().map(|&(a, b, _)| (a, b)));
14451443
let (mut auto_traits, regular_traits): (Vec<_>, Vec<_>) =
14461444
expanded_traits.partition(|i| tcx.trait_is_auto(i.trait_ref().def_id()));
14471445
if regular_traits.len() > 1 {

src/librustdoc/html/render.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -3627,14 +3627,7 @@ fn render_impl(
36273627
for it in &i.inner_impl().items {
36283628
if let clean::TypedefItem(ref tydef, _) = it.inner {
36293629
write!(w, "<span class=\"where fmt-newline\"> ");
3630-
assoc_type(
3631-
w,
3632-
it,
3633-
&vec![],
3634-
Some(&tydef.type_),
3635-
AssocItemLink::Anchor(None),
3636-
"",
3637-
);
3630+
assoc_type(w, it, &[], Some(&tydef.type_), AssocItemLink::Anchor(None), "");
36383631
write!(w, ";</span>");
36393632
}
36403633
}

0 commit comments

Comments
 (0)