From 24e876b52ed76710593895bc37bb8ed303075193 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Mon, 5 Apr 2021 02:03:37 +0200 Subject: Intern more `TypeRef`s in generics Saves ~3 MB --- crates/hir_ty/src/utils.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/utils.rs b/crates/hir_ty/src/utils.rs index b23e91b1b..c85c328af 100644 --- a/crates/hir_ty/src/utils.rs +++ b/crates/hir_ty/src/utils.rs @@ -32,11 +32,10 @@ fn direct_super_traits(db: &dyn DefDatabase, trait_: TraitId) -> Vec { .filter_map(|pred| match pred { WherePredicate::ForLifetime { target, bound, .. } | WherePredicate::TypeBound { target, bound } => match target { - WherePredicateTypeTarget::TypeRef(TypeRef::Path(p)) - if p == &Path::from(name![Self]) => - { - bound.as_path() - } + WherePredicateTypeTarget::TypeRef(type_ref) => match &**type_ref { + TypeRef::Path(p) if p == &Path::from(name![Self]) => bound.as_path(), + _ => None, + }, WherePredicateTypeTarget::TypeParam(local_id) if Some(*local_id) == trait_self => { bound.as_path() } -- cgit v1.2.3 From 7c0c713a102ee86ee32af115acba63a5c3b3a657 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Mon, 5 Apr 2021 03:50:10 +0200 Subject: Intern `GenericParams` Also share the same instance between `ItemTree` and `generic_params` query. --- crates/hir_ty/src/utils.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/utils.rs b/crates/hir_ty/src/utils.rs index c85c328af..df0ea4368 100644 --- a/crates/hir_ty/src/utils.rs +++ b/crates/hir_ty/src/utils.rs @@ -9,6 +9,7 @@ use hir_def::{ generics::{ GenericParams, TypeParamData, TypeParamProvenance, WherePredicate, WherePredicateTypeTarget, }, + intern::Interned, path::Path, resolver::{HasResolver, TypeNs}, type_ref::TypeRef, @@ -158,7 +159,7 @@ pub(crate) fn generics(db: &dyn DefDatabase, def: GenericDefId) -> Generics { #[derive(Debug)] pub(crate) struct Generics { def: GenericDefId, - pub(crate) params: Arc, + pub(crate) params: Interned, parent_generics: Option>, } -- cgit v1.2.3