Auto merge of #93643 - lcnr:fold-substs-perf, r=michaelwoerister

use `fold_list` in `try_super_fold_with` for `SubstsRef`

split out from #93505 as this by itself is responsible for most of the perf improvements there

r? `@michaelwoerister`
This commit is contained in:
bors 2022-02-07 03:47:47 +00:00
commit 926e7843ea

View File

@ -396,15 +396,7 @@ impl<'tcx> TypeFoldable<'tcx> for SubstsRef<'tcx> {
} }
} }
0 => Ok(self), 0 => Ok(self),
_ => { _ => ty::util::fold_list(self, folder, |tcx, v| tcx.intern_substs(v)),
let params: SmallVec<[_; 8]> =
self.iter().map(|k| k.try_fold_with(folder)).collect::<Result<_, _>>()?;
if params[..] == self[..] {
Ok(self)
} else {
Ok(folder.tcx().intern_substs(&params))
}
}
} }
} }