From 07ba986db7b9f7c275bc2b6a32487e0aa8b70864 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 1 Jul 2020 15:19:36 +0200 Subject: Don't recursively call `impls_from_deps` It creates a big map and duplicates lots of impls that are then left lying around --- crates/ra_hir_ty/src/method_resolution.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'crates/ra_hir_ty/src') diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/ra_hir_ty/src/method_resolution.rs index c19519cf1..201604e1d 100644 --- a/crates/ra_hir_ty/src/method_resolution.rs +++ b/crates/ra_hir_ty/src/method_resolution.rs @@ -72,13 +72,8 @@ impl CrateImplDefs { impls_by_trait: FxHashMap::default(), }; - // For each dependency, calculate `impls_from_deps` recursively, then add its own - // `impls_in_crate`. - // As we might visit crates multiple times, `merge` has to deduplicate impls to avoid - // wasting memory. - for dep in &crate_graph[krate].dependencies { - res.merge(&db.impls_from_deps(dep.crate_id)); - res.merge(&db.impls_in_crate(dep.crate_id)); + for krate in crate_graph.transitive_deps(krate) { + res.merge(&db.impls_in_crate(krate)); } Arc::new(res) @@ -114,8 +109,6 @@ impl CrateImplDefs { for (fp, impls) in &other.inherent_impls { let vec = self.inherent_impls.entry(*fp).or_default(); vec.extend(impls); - vec.sort(); - vec.dedup(); } for (trait_, other_map) in &other.impls_by_trait { @@ -123,8 +116,6 @@ impl CrateImplDefs { for (fp, impls) in other_map { let vec = map.entry(*fp).or_default(); vec.extend(impls); - vec.sort(); - vec.dedup(); } } } -- cgit v1.2.3