Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Avoid more unnecessary mk_ty calls in Ty::super_fold_with.
This speeds up several rustc-benchmarks by 1--5%.
  • Loading branch information
nnethercote committed Nov 24, 2016
1 parent 82d8833 commit 4d0618e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/librustc/ty/structural_impls.rs
Expand Up @@ -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 {
Expand Down

0 comments on commit 4d0618e

Please sign in to comment.