aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-04-08 17:32:20 +0100
committerFlorian Diebold <[email protected]>2021-04-08 21:48:47 +0100
commit37cb6805afc397adf769391cec99b2e11d0d52e0 (patch)
tree4fa7eb0e13bfd254ff9b6bb09d7af4d1b996551a /crates/hir_ty
parentbe03db0e3a75533f34d48c3014d532919b30a9e9 (diff)
Intern types
Performance about the same, memory reduced by ~5%.
Diffstat (limited to 'crates/hir_ty')
-rw-r--r--crates/hir_ty/src/traits/chalk/interner.rs10
1 files changed, 7 insertions, 3 deletions
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<chalk_ir::VariableKind<Interner>>);
36#[derive(PartialEq, Eq, Hash, Debug)] 36#[derive(PartialEq, Eq, Hash, Debug)]
37pub struct InternedSubstitutionInner(SmallVec<[GenericArg; 2]>); 37pub struct InternedSubstitutionInner(SmallVec<[GenericArg; 2]>);
38 38
39#[derive(PartialEq, Eq, Hash, Debug)]
40pub struct InternedTypeInner(chalk_ir::TyData<Interner>);
41
39impl_internable!( 42impl_internable!(
40 InternedVariableKindsInner, 43 InternedVariableKindsInner,
41 InternedSubstitutionInner, 44 InternedSubstitutionInner,
45 InternedTypeInner,
42); 46);
43 47
44impl chalk_ir::interner::Interner for Interner { 48impl chalk_ir::interner::Interner for Interner {
45 type InternedType = Arc<chalk_ir::TyData<Self>>; 49 type InternedType = Interned<InternedTypeInner>;
46 type InternedLifetime = chalk_ir::LifetimeData<Self>; 50 type InternedLifetime = chalk_ir::LifetimeData<Self>;
47 type InternedConst = Arc<chalk_ir::ConstData<Self>>; 51 type InternedConst = Arc<chalk_ir::ConstData<Self>>;
48 type InternedConcreteConst = (); 52 type InternedConcreteConst = ();
@@ -209,11 +213,11 @@ impl chalk_ir::interner::Interner for Interner {
209 213
210 fn intern_ty(&self, kind: chalk_ir::TyKind<Self>) -> Self::InternedType { 214 fn intern_ty(&self, kind: chalk_ir::TyKind<Self>) -> Self::InternedType {
211 let flags = kind.compute_flags(self); 215 let flags = kind.compute_flags(self);
212 Arc::new(chalk_ir::TyData { kind, flags }) 216 Interned::new(InternedTypeInner(chalk_ir::TyData { kind, flags }))
213 } 217 }
214 218
215 fn ty_data<'a>(&self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData<Self> { 219 fn ty_data<'a>(&self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData<Self> {
216 ty 220 &ty.0
217 } 221 }
218 222
219 fn intern_lifetime(&self, lifetime: chalk_ir::LifetimeData<Self>) -> Self::InternedLifetime { 223 fn intern_lifetime(&self, lifetime: chalk_ir::LifetimeData<Self>) -> Self::InternedLifetime {