Skip to content

Commit fe1314d

Browse files
committed
fix couple of perf related clipyp 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
1 parent 8417d68 commit fe1314d

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
@@ -1344,7 +1344,7 @@ pub trait ToPredicate<'tcx> {
13441344
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<TraitRef<'tcx>> {
13451345
fn to_predicate(&self) -> Predicate<'tcx> {
13461346
ty::Predicate::Trait(
1347-
ty::Binder::dummy(ty::TraitPredicate { trait_ref: self.value.clone() }),
1347+
ty::Binder::dummy(ty::TraitPredicate { trait_ref: self.value }),
13481348
self.constness,
13491349
)
13501350
}

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
@@ -3629,14 +3629,7 @@ fn render_impl(
36293629
for it in &i.inner_impl().items {
36303630
if let clean::TypedefItem(ref tydef, _) = it.inner {
36313631
write!(w, "<span class=\"where fmt-newline\"> ");
3632-
assoc_type(
3633-
w,
3634-
it,
3635-
&vec![],
3636-
Some(&tydef.type_),
3637-
AssocItemLink::Anchor(None),
3638-
"",
3639-
);
3632+
assoc_type(w, it, &[], Some(&tydef.type_), AssocItemLink::Anchor(None), "");
36403633
write!(w, ";</span>");
36413634
}
36423635
}

0 commit comments

Comments
 (0)