Remove redundancy in cache key

This commit is contained in:
Tyler Mandry 2020-09-18 06:07:19 +00:00
parent f583513dc2
commit 3ccb1c37e6
2 changed files with 4 additions and 5 deletions

View File

@ -500,7 +500,7 @@ struct Generalizer<'cx, 'tcx> {
param_env: ty::ParamEnv<'tcx>,
cache: MiniMap<(Ty<'tcx>, Ty<'tcx>), RelateResult<'tcx, Ty<'tcx>>>,
cache: MiniMap<Ty<'tcx>, RelateResult<'tcx, Ty<'tcx>>>,
}
/// Result from a generalization operation. This includes
@ -598,8 +598,7 @@ fn relate_with_variance<T: Relate<'tcx>>(
fn tys(&mut self, t: Ty<'tcx>, t2: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
assert_eq!(t, t2); // we are abusing TypeRelation here; both LHS and RHS ought to be ==
let cache_key = (t, t2);
if let Some(result) = self.cache.get(&cache_key) {
if let Some(result) = self.cache.get(&t) {
return result.clone();
}
debug!("generalize: t={:?}", t);
@ -667,7 +666,7 @@ fn tys(&mut self, t: Ty<'tcx>, t2: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
_ => relate::super_relate_tys(self, t, t),
};
self.cache.insert(cache_key, result.clone());
self.cache.insert(t, result.clone());
return result;
}

View File

@ -265,7 +265,7 @@ fn default_print_impl_path(
/// type. It's just a heuristic so it makes some questionable
/// decisions and we may want to adjust it later.
///
/// Visited set is needed in to avoid full iteration over
/// Visited set is needed to avoid full iteration over
/// deeply nested tuples that have no DefId.
fn characteristic_def_id_of_type_cached<'a>(
ty: Ty<'a>,