Skip to content

Commit 37cb680

Browse files
committed
Intern types
Performance about the same, memory reduced by ~5%.
1 parent be03db0 commit 37cb680

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

crates/hir_ty/src/traits/chalk/interner.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@ pub struct InternedVariableKindsInner(Vec<chalk_ir::VariableKind<Interner>>);
3636
#[derive(PartialEq, Eq, Hash, Debug)]
3737
pub struct InternedSubstitutionInner(SmallVec<[GenericArg; 2]>);
3838

39+
#[derive(PartialEq, Eq, Hash, Debug)]
40+
pub struct InternedTypeInner(chalk_ir::TyData<Interner>);
41+
3942
impl_internable!(
4043
InternedVariableKindsInner,
4144
InternedSubstitutionInner,
45+
InternedTypeInner,
4246
);
4347

4448
impl chalk_ir::interner::Interner for Interner {
45-
type InternedType = Arc<chalk_ir::TyData<Self>>;
49+
type InternedType = Interned<InternedTypeInner>;
4650
type InternedLifetime = chalk_ir::LifetimeData<Self>;
4751
type InternedConst = Arc<chalk_ir::ConstData<Self>>;
4852
type InternedConcreteConst = ();
@@ -209,11 +213,11 @@ impl chalk_ir::interner::Interner for Interner {
209213

210214
fn intern_ty(&self, kind: chalk_ir::TyKind<Self>) -> Self::InternedType {
211215
let flags = kind.compute_flags(self);
212-
Arc::new(chalk_ir::TyData { kind, flags })
216+
Interned::new(InternedTypeInner(chalk_ir::TyData { kind, flags }))
213217
}
214218

215219
fn ty_data<'a>(&self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData<Self> {
216-
ty
220+
&ty.0
217221
}
218222

219223
fn intern_lifetime(&self, lifetime: chalk_ir::LifetimeData<Self>) -> Self::InternedLifetime {

0 commit comments

Comments
 (0)