diff options
| author | Nicholas Nethercote <nnethercote@mozilla.com> | 2016-11-24 21:10:08 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <nnethercote@mozilla.com> | 2016-11-24 21:11:05 +1100 |
| commit | 4d0618ee3014b96287bb6914296b78bd474b0290 (patch) | |
| tree | 32597a9cc51ecbb097666940a2769675e1b871fc | |
| parent | 82d8833a456a408fe8b761a3b5e88475b65066c8 (diff) | |
| download | rust-4d0618ee3014b96287bb6914296b78bd474b0290.tar.gz rust-4d0618ee3014b96287bb6914296b78bd474b0290.zip | |
Avoid more unnecessary mk_ty calls in Ty::super_fold_with.
This speeds up several rustc-benchmarks by 1--5%.
| -rw-r--r-- | src/librustc/ty/structural_impls.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/librustc/ty/structural_impls.rs b/src/librustc/ty/structural_impls.rs index e73be23a42c..877da7ee3b5 100644 --- a/src/librustc/ty/structural_impls.rs +++ b/src/librustc/ty/structural_impls.rs @@ -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 { |
