Skip to content

Commit 4d0618e

Browse files
committed
Avoid more unnecessary mk_ty calls in Ty::super_fold_with.
This speeds up several rustc-benchmarks by 1--5%.
1 parent 82d8833 commit 4d0618e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/librustc/ty/structural_impls.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,12 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
481481
ty::TyUint(_) | ty::TyFloat(_) | ty::TyError | ty::TyInfer(_) |
482482
ty::TyParam(..) | ty::TyNever => return self
483483
};
484-
folder.tcx().mk_ty(sty)
484+
485+
if self.sty == sty {
486+
self
487+
} else {
488+
folder.tcx().mk_ty(sty)
489+
}
485490
}
486491

487492
fn fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {

0 commit comments

Comments
 (0)