diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-04-08 22:11:53 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-08 22:11:53 +0100 |
commit | a75763cd57ac6d9cd08846770b8c5f5ba27122df (patch) | |
tree | d33b6ca6fc37c3eaf19980926fa2dd0d59e66b43 /crates/hir_ty/src/infer | |
parent | 63726a91b721e119622e0c7ea106fc5c2e866bf3 (diff) | |
parent | 37ff15ad835ee4ba6d231cac8b1adbd301aec20b (diff) |
Merge #8433
8433: Intern lots of things r=jonas-schievink a=flodiebold
This uses the new interning infrastructure for most type-related things, where it had a positive effect on memory usage and performance. In total, this gives a slight performance improvement and a quite good memory reduction (1119MB->885MB on RA, 1774MB->1188MB on Diesel).
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/infer')
-rw-r--r-- | crates/hir_ty/src/infer/expr.rs | 6 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/pat.rs | 4 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/path.rs | 2 |
3 files changed, 8 insertions, 4 deletions
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index cbbfa8b5c..7961f4a52 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -462,7 +462,11 @@ impl<'a> InferenceContext<'a> { | |||
462 | }; | 462 | }; |
463 | match canonicalized.decanonicalize_ty(derefed_ty.value).kind(&Interner) { | 463 | match canonicalized.decanonicalize_ty(derefed_ty.value).kind(&Interner) { |
464 | TyKind::Tuple(_, substs) => name.as_tuple_index().and_then(|idx| { | 464 | TyKind::Tuple(_, substs) => name.as_tuple_index().and_then(|idx| { |
465 | substs.interned().get(idx).map(|a| a.assert_ty_ref(&Interner)).cloned() | 465 | substs |
466 | .as_slice(&Interner) | ||
467 | .get(idx) | ||
468 | .map(|a| a.assert_ty_ref(&Interner)) | ||
469 | .cloned() | ||
466 | }), | 470 | }), |
467 | TyKind::Adt(AdtId(hir_def::AdtId::StructId(s)), parameters) => { | 471 | TyKind::Adt(AdtId(hir_def::AdtId::StructId(s)), parameters) => { |
468 | let local_id = self.db.struct_data(*s).variant_data.field(name)?; | 472 | let local_id = self.db.struct_data(*s).variant_data.field(name)?; |
diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index a41e8e116..aea354cde 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs | |||
@@ -122,7 +122,7 @@ impl<'a> InferenceContext<'a> { | |||
122 | let ty = match &body[pat] { | 122 | let ty = match &body[pat] { |
123 | &Pat::Tuple { ref args, ellipsis } => { | 123 | &Pat::Tuple { ref args, ellipsis } => { |
124 | let expectations = match expected.as_tuple() { | 124 | let expectations = match expected.as_tuple() { |
125 | Some(parameters) => &*parameters.interned().as_slice(), | 125 | Some(parameters) => &*parameters.as_slice(&Interner), |
126 | _ => &[], | 126 | _ => &[], |
127 | }; | 127 | }; |
128 | 128 | ||
@@ -242,7 +242,7 @@ impl<'a> InferenceContext<'a> { | |||
242 | let (inner_ty, alloc_ty) = match expected.as_adt() { | 242 | let (inner_ty, alloc_ty) = match expected.as_adt() { |
243 | Some((adt, subst)) if adt == box_adt => ( | 243 | Some((adt, subst)) if adt == box_adt => ( |
244 | subst.at(&Interner, 0).assert_ty_ref(&Interner).clone(), | 244 | subst.at(&Interner, 0).assert_ty_ref(&Interner).clone(), |
245 | subst.interned().get(1).and_then(|a| a.ty(&Interner).cloned()), | 245 | subst.as_slice(&Interner).get(1).and_then(|a| a.ty(&Interner).cloned()), |
246 | ), | 246 | ), |
247 | _ => (self.result.standard_types.unknown.clone(), None), | 247 | _ => (self.result.standard_types.unknown.clone(), None), |
248 | }; | 248 | }; |
diff --git a/crates/hir_ty/src/infer/path.rs b/crates/hir_ty/src/infer/path.rs index f8955aa32..495282eba 100644 --- a/crates/hir_ty/src/infer/path.rs +++ b/crates/hir_ty/src/infer/path.rs | |||
@@ -101,7 +101,7 @@ impl<'a> InferenceContext<'a> { | |||
101 | let substs = ctx.substs_from_path(path, typable, true); | 101 | let substs = ctx.substs_from_path(path, typable, true); |
102 | let ty = TyBuilder::value_ty(self.db, typable) | 102 | let ty = TyBuilder::value_ty(self.db, typable) |
103 | .use_parent_substs(&parent_substs) | 103 | .use_parent_substs(&parent_substs) |
104 | .fill(substs.interned()[parent_substs.len(&Interner)..].iter().cloned()) | 104 | .fill(substs.as_slice(&Interner)[parent_substs.len(&Interner)..].iter().cloned()) |
105 | .build(); | 105 | .build(); |
106 | Some(ty) | 106 | Some(ty) |
107 | } | 107 | } |