fix small perf regressions

This commit is contained in:
Ali MJ Al-Nasrawy 2023-12-06 07:22:44 +00:00
parent 85338197d4
commit a1459c3fca

View File

@ -34,7 +34,7 @@
use crate::infer::MemberConstraint; use crate::infer::MemberConstraint;
use crate::mir::ConstraintCategory; use crate::mir::ConstraintCategory;
use crate::ty::GenericArg; use crate::ty::GenericArg;
use crate::ty::{self, BoundVar, List, Region, Ty, TyCtxt}; use crate::ty::{self, BoundVar, List, Region, Ty, TyCtxt, TypeFlags, TypeVisitableExt};
pub type Canonical<'tcx, V> = IrCanonical<TyCtxt<'tcx>, V>; pub type Canonical<'tcx, V> = IrCanonical<TyCtxt<'tcx>, V>;
@ -315,6 +315,16 @@ pub fn get_or_insert(
&mut OriginalQueryValues<'tcx>, &mut OriginalQueryValues<'tcx>,
) -> Canonical<'tcx, ty::ParamEnv<'tcx>>, ) -> Canonical<'tcx, ty::ParamEnv<'tcx>>,
) -> Canonical<'tcx, ty::ParamEnv<'tcx>> { ) -> Canonical<'tcx, ty::ParamEnv<'tcx>> {
if !key.has_type_flags(
TypeFlags::HAS_INFER | TypeFlags::HAS_PLACEHOLDER | TypeFlags::HAS_FREE_REGIONS,
) {
return Canonical {
max_universe: ty::UniverseIndex::ROOT,
variables: List::empty(),
value: key,
};
}
assert_eq!(state.var_values.len(), 0); assert_eq!(state.var_values.len(), 0);
assert_eq!(state.universe_map.len(), 1); assert_eq!(state.universe_map.len(), 1);
debug_assert_eq!(&*state.universe_map, &[ty::UniverseIndex::ROOT]); debug_assert_eq!(&*state.universe_map, &[ty::UniverseIndex::ROOT]);