diff options
author | Florian Diebold <[email protected]> | 2021-04-08 17:32:20 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-04-08 21:48:47 +0100 |
commit | 37cb6805afc397adf769391cec99b2e11d0d52e0 (patch) | |
tree | 4fa7eb0e13bfd254ff9b6bb09d7af4d1b996551a /crates/hir_ty/src/traits | |
parent | be03db0e3a75533f34d48c3014d532919b30a9e9 (diff) |
Intern types
Performance about the same, memory reduced by ~5%.
Diffstat (limited to 'crates/hir_ty/src/traits')
-rw-r--r-- | crates/hir_ty/src/traits/chalk/interner.rs | 10 |
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)] |
37 | pub struct InternedSubstitutionInner(SmallVec<[GenericArg; 2]>); | 37 | pub struct InternedSubstitutionInner(SmallVec<[GenericArg; 2]>); |
38 | 38 | ||
39 | #[derive(PartialEq, Eq, Hash, Debug)] | ||
40 | pub struct InternedTypeInner(chalk_ir::TyData<Interner>); | ||
41 | |||
39 | impl_internable!( | 42 | impl_internable!( |
40 | InternedVariableKindsInner, | 43 | InternedVariableKindsInner, |
41 | InternedSubstitutionInner, | 44 | InternedSubstitutionInner, |
45 | InternedTypeInner, | ||
42 | ); | 46 | ); |
43 | 47 | ||
44 | impl chalk_ir::interner::Interner for Interner { | 48 | impl 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 { |