Avoid more unnecessary mk_ty calls in Ty::super_fold_with.

This speeds up several rustc-benchmarks by 1--5%.
This commit is contained in:
Nicholas Nethercote 2016-11-24 21:10:08 +11:00
parent 82d8833a45
commit 4d0618ee30

View File

@ -481,7 +481,12 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
ty::TyUint(_) | ty::TyFloat(_) | ty::TyError | ty::TyInfer(_) |
ty::TyParam(..) | ty::TyNever => return self
};
folder.tcx().mk_ty(sty)
if self.sty == sty {
self
} else {
folder.tcx().mk_ty(sty)
}
}
fn fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {