]> git.lizzy.rs Git - rust.git/commitdiff
Avoid unnecessary mk_ty calls in Ty::super_fold_with.
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 11 Nov 2016 04:56:58 +0000 (15:56 +1100)
committerNicholas Nethercote <nnethercote@mozilla.com>
Fri, 11 Nov 2016 04:56:58 +0000 (15:56 +1100)
This speeds up compilation of several rustc-benchmarks by 1--2% and the
workload in #36799 by 5%.

src/librustc/ty/structural_impls.rs

index 9ca911837b517855e3dcbce3e0aa5c69b22a4bfd..282cb9f80f51e46a5672c17d880d1df050bc312c 100644 (file)
@@ -482,7 +482,7 @@ fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F)
             ty::TyAnon(did, substs) => ty::TyAnon(did, substs.fold_with(folder)),
             ty::TyBool | ty::TyChar | ty::TyStr | ty::TyInt(_) |
             ty::TyUint(_) | ty::TyFloat(_) | ty::TyError | ty::TyInfer(_) |
-            ty::TyParam(..) | ty::TyNever => self.sty.clone(),
+            ty::TyParam(..) | ty::TyNever => return self
         };
         folder.tcx().mk_ty(sty)
     }