aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2020-07-01 14:19:36 +0100
committerJonas Schievink <[email protected]>2020-07-01 14:19:36 +0100
commit07ba986db7b9f7c275bc2b6a32487e0aa8b70864 (patch)
tree85bc94c7081aa8fb843eec1e7746ff8c8b0d3d21 /crates
parent63ea8f2af097316523f54f09e1c54d515a1bb9fd (diff)
Don't recursively call `impls_from_deps`
It creates a big map and duplicates lots of impls that are then left lying around
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir_ty/src/method_resolution.rs13
1 files changed, 2 insertions, 11 deletions
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 {
72 impls_by_trait: FxHashMap::default(), 72 impls_by_trait: FxHashMap::default(),
73 }; 73 };
74 74
75 // For each dependency, calculate `impls_from_deps` recursively, then add its own 75 for krate in crate_graph.transitive_deps(krate) {
76 // `impls_in_crate`. 76 res.merge(&db.impls_in_crate(krate));
77 // As we might visit crates multiple times, `merge` has to deduplicate impls to avoid
78 // wasting memory.
79 for dep in &crate_graph[krate].dependencies {
80 res.merge(&db.impls_from_deps(dep.crate_id));
81 res.merge(&db.impls_in_crate(dep.crate_id));
82 } 77 }
83 78
84 Arc::new(res) 79 Arc::new(res)
@@ -114,8 +109,6 @@ impl CrateImplDefs {
114 for (fp, impls) in &other.inherent_impls { 109 for (fp, impls) in &other.inherent_impls {
115 let vec = self.inherent_impls.entry(*fp).or_default(); 110 let vec = self.inherent_impls.entry(*fp).or_default();
116 vec.extend(impls); 111 vec.extend(impls);
117 vec.sort();
118 vec.dedup();
119 } 112 }
120 113
121 for (trait_, other_map) in &other.impls_by_trait { 114 for (trait_, other_map) in &other.impls_by_trait {
@@ -123,8 +116,6 @@ impl CrateImplDefs {
123 for (fp, impls) in other_map { 116 for (fp, impls) in other_map {
124 let vec = map.entry(*fp).or_default(); 117 let vec = map.entry(*fp).or_default();
125 vec.extend(impls); 118 vec.extend(impls);
126 vec.sort();
127 vec.dedup();
128 } 119 }
129 } 120 }
130 } 121 }