From 37cb6805afc397adf769391cec99b2e11d0d52e0 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 8 Apr 2021 18:32:20 +0200 Subject: Intern types Performance about the same, memory reduced by ~5%. --- crates/hir_ty/src/traits/chalk/interner.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'crates/hir_ty/src/traits/chalk') diff --git a/crates/hir_ty/src/traits/chalk/interner.rs b/crates/hir_ty/src/traits/chalk/interner.rs index 17e056f03..83787b8c0 100644 --- a/crates/hir_ty/src/traits/chalk/interner.rs +++ b/crates/hir_ty/src/traits/chalk/interner.rs @@ -36,13 +36,17 @@ pub struct InternedVariableKindsInner(Vec>); #[derive(PartialEq, Eq, Hash, Debug)] pub struct InternedSubstitutionInner(SmallVec<[GenericArg; 2]>); +#[derive(PartialEq, Eq, Hash, Debug)] +pub struct InternedTypeInner(chalk_ir::TyData); + impl_internable!( InternedVariableKindsInner, InternedSubstitutionInner, + InternedTypeInner, ); impl chalk_ir::interner::Interner for Interner { - type InternedType = Arc>; + type InternedType = Interned; type InternedLifetime = chalk_ir::LifetimeData; type InternedConst = Arc>; type InternedConcreteConst = (); @@ -209,11 +213,11 @@ impl chalk_ir::interner::Interner for Interner { fn intern_ty(&self, kind: chalk_ir::TyKind) -> Self::InternedType { let flags = kind.compute_flags(self); - Arc::new(chalk_ir::TyData { kind, flags }) + Interned::new(InternedTypeInner(chalk_ir::TyData { kind, flags })) } fn ty_data<'a>(&self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData { - ty + &ty.0 } fn intern_lifetime(&self, lifetime: chalk_ir::LifetimeData) -> Self::InternedLifetime { -- cgit v1.2.3