diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-04-02 17:43:16 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-02 17:43:16 +0100 |
commit | f4d56989b657b15aec6675cf1ba697e3f87eb088 (patch) | |
tree | 23e4d8265444257f2e4018a003659a711fde0414 /crates/hir | |
parent | 9bcdbefc7b657f34704439d068113180b14359dc (diff) | |
parent | 6e227b80a7686a7ea5bc039d54c307fda29c99ba (diff) |
Merge #8284
8284: Reduce memory usage by using global `Arc`-based interning r=jonas-schievink a=jonas-schievink
This saves around 50 mb when running `analysis-stats` on r-a itself. Not a lot, but this infra can be easily reused to intern more stuff.
Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir')
-rw-r--r-- | crates/hir/src/display.rs | 2 | ||||
-rw-r--r-- | crates/hir/src/lib.rs | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/crates/hir/src/display.rs b/crates/hir/src/display.rs index 97a78ca25..ab04c55bc 100644 --- a/crates/hir/src/display.rs +++ b/crates/hir/src/display.rs | |||
@@ -91,7 +91,7 @@ impl HirDisplay for Function { | |||
91 | let ret_type = if !qual.is_async { | 91 | let ret_type = if !qual.is_async { |
92 | &data.ret_type | 92 | &data.ret_type |
93 | } else { | 93 | } else { |
94 | match &data.ret_type { | 94 | match &*data.ret_type { |
95 | TypeRef::ImplTrait(bounds) => match &bounds[0] { | 95 | TypeRef::ImplTrait(bounds) => match &bounds[0] { |
96 | TypeBound::Path(path) => { | 96 | TypeBound::Path(path) => { |
97 | path.segments().iter().last().unwrap().args_and_bindings.unwrap().bindings | 97 | path.segments().iter().last().unwrap().args_and_bindings.unwrap().bindings |
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 97f162315..06fd6542d 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -957,7 +957,7 @@ impl SelfParam { | |||
957 | func_data | 957 | func_data |
958 | .params | 958 | .params |
959 | .first() | 959 | .first() |
960 | .map(|param| match *param { | 960 | .map(|param| match &**param { |
961 | TypeRef::Reference(.., mutability) => match mutability { | 961 | TypeRef::Reference(.., mutability) => match mutability { |
962 | hir_def::type_ref::Mutability::Shared => Access::Shared, | 962 | hir_def::type_ref::Mutability::Shared => Access::Shared, |
963 | hir_def::type_ref::Mutability::Mut => Access::Exclusive, | 963 | hir_def::type_ref::Mutability::Mut => Access::Exclusive, |
@@ -1011,7 +1011,7 @@ impl Const { | |||
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | pub fn type_ref(self, db: &dyn HirDatabase) -> TypeRef { | 1013 | pub fn type_ref(self, db: &dyn HirDatabase) -> TypeRef { |
1014 | db.const_data(self.id).type_ref.clone() | 1014 | db.const_data(self.id).type_ref.as_ref().clone() |
1015 | } | 1015 | } |
1016 | } | 1016 | } |
1017 | 1017 | ||
@@ -1101,7 +1101,7 @@ impl TypeAlias { | |||
1101 | } | 1101 | } |
1102 | 1102 | ||
1103 | pub fn type_ref(self, db: &dyn HirDatabase) -> Option<TypeRef> { | 1103 | pub fn type_ref(self, db: &dyn HirDatabase) -> Option<TypeRef> { |
1104 | db.type_alias_data(self.id).type_ref.clone() | 1104 | db.type_alias_data(self.id).type_ref.as_deref().cloned() |
1105 | } | 1105 | } |
1106 | 1106 | ||
1107 | pub fn ty(self, db: &dyn HirDatabase) -> Type { | 1107 | pub fn ty(self, db: &dyn HirDatabase) -> Type { |
@@ -1615,7 +1615,7 @@ impl Impl { | |||
1615 | // FIXME: the return type is wrong. This should be a hir version of | 1615 | // FIXME: the return type is wrong. This should be a hir version of |
1616 | // `TraitRef` (ie, resolved `TypeRef`). | 1616 | // `TraitRef` (ie, resolved `TypeRef`). |
1617 | pub fn trait_(self, db: &dyn HirDatabase) -> Option<TraitRef> { | 1617 | pub fn trait_(self, db: &dyn HirDatabase) -> Option<TraitRef> { |
1618 | db.impl_data(self.id).target_trait.clone() | 1618 | db.impl_data(self.id).target_trait.as_deref().cloned() |
1619 | } | 1619 | } |
1620 | 1620 | ||
1621 | pub fn self_ty(self, db: &dyn HirDatabase) -> Type { | 1621 | pub fn self_ty(self, db: &dyn HirDatabase) -> Type { |