Inline UnifyKey::index and UnifyKey::from_index

This commit is contained in:
Tomasz Miąsko 2022-02-10 00:00:00 +00:00
parent 5569757491
commit cd37638c14
4 changed files with 12 additions and 0 deletions

View file

@ -416,6 +416,7 @@ impl<'tcx> ut::UnifyKey for TyVidEqKey<'tcx> {
fn index(&self) -> u32 { fn index(&self) -> u32 {
self.vid.as_u32() self.vid.as_u32()
} }
#[inline]
fn from_index(i: u32) -> Self { fn from_index(i: u32) -> Self {
TyVidEqKey::from(ty::TyVid::from_u32(i)) TyVidEqKey::from(ty::TyVid::from_u32(i))
} }

View file

@ -32,9 +32,11 @@ impl<'tcx> From<ty::RegionVid> for RegionVidKey<'tcx> {
impl<'tcx> UnifyKey for RegionVidKey<'tcx> { impl<'tcx> UnifyKey for RegionVidKey<'tcx> {
type Value = UnifiedRegion<'tcx>; type Value = UnifiedRegion<'tcx>;
#[inline]
fn index(&self) -> u32 { fn index(&self) -> u32 {
self.vid.as_u32() self.vid.as_u32()
} }
#[inline]
fn from_index(i: u32) -> Self { fn from_index(i: u32) -> Self {
RegionVidKey::from(ty::RegionVid::from_u32(i)) RegionVidKey::from(ty::RegionVid::from_u32(i))
} }
@ -118,9 +120,11 @@ pub struct ConstVarValue<'tcx> {
impl<'tcx> UnifyKey for ty::ConstVid<'tcx> { impl<'tcx> UnifyKey for ty::ConstVid<'tcx> {
type Value = ConstVarValue<'tcx>; type Value = ConstVarValue<'tcx>;
#[inline]
fn index(&self) -> u32 { fn index(&self) -> u32 {
self.index self.index
} }
#[inline]
fn from_index(i: u32) -> Self { fn from_index(i: u32) -> Self {
ty::ConstVid { index: i, phantom: PhantomData } ty::ConstVid { index: i, phantom: PhantomData }
} }

View file

@ -222,9 +222,11 @@ impl From<Local> for UnifyLocal {
impl UnifyKey for UnifyLocal { impl UnifyKey for UnifyLocal {
type Value = (); type Value = ();
#[inline]
fn index(&self) -> u32 { fn index(&self) -> u32 {
self.0.as_u32() self.0.as_u32()
} }
#[inline]
fn from_index(u: u32) -> Self { fn from_index(u: u32) -> Self {
Self(Local::from_u32(u)) Self(Local::from_u32(u))
} }

View file

@ -400,9 +400,11 @@ pub enum InferTy {
/// they carry no values. /// they carry no values.
impl UnifyKey for TyVid { impl UnifyKey for TyVid {
type Value = (); type Value = ();
#[inline]
fn index(&self) -> u32 { fn index(&self) -> u32 {
self.as_u32() self.as_u32()
} }
#[inline]
fn from_index(i: u32) -> TyVid { fn from_index(i: u32) -> TyVid {
TyVid::from_u32(i) TyVid::from_u32(i)
} }
@ -419,6 +421,7 @@ impl UnifyKey for IntVid {
fn index(&self) -> u32 { fn index(&self) -> u32 {
self.index self.index
} }
#[inline]
fn from_index(i: u32) -> IntVid { fn from_index(i: u32) -> IntVid {
IntVid { index: i } IntVid { index: i }
} }
@ -431,9 +434,11 @@ impl EqUnifyValue for FloatVarValue {}
impl UnifyKey for FloatVid { impl UnifyKey for FloatVid {
type Value = Option<FloatVarValue>; type Value = Option<FloatVarValue>;
#[inline]
fn index(&self) -> u32 { fn index(&self) -> u32 {
self.index self.index
} }
#[inline]
fn from_index(i: u32) -> FloatVid { fn from_index(i: u32) -> FloatVid {
FloatVid { index: i } FloatVid { index: i }
} }