Skip to content

Commit 07ba986

Browse files
author
Jonas Schievink
committed
Don't recursively call impls_from_deps
It creates a big map and duplicates lots of impls that are then left lying around
1 parent 63ea8f2 commit 07ba986

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

crates/ra_hir_ty/src/method_resolution.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,8 @@ impl CrateImplDefs {
7272
impls_by_trait: FxHashMap::default(),
7373
};
7474

75-
// For each dependency, calculate `impls_from_deps` recursively, then add its own
76-
// `impls_in_crate`.
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));
75+
for krate in crate_graph.transitive_deps(krate) {
76+
res.merge(&db.impls_in_crate(krate));
8277
}
8378

8479
Arc::new(res)
@@ -114,17 +109,13 @@ impl CrateImplDefs {
114109
for (fp, impls) in &other.inherent_impls {
115110
let vec = self.inherent_impls.entry(*fp).or_default();
116111
vec.extend(impls);
117-
vec.sort();
118-
vec.dedup();
119112
}
120113

121114
for (trait_, other_map) in &other.impls_by_trait {
122115
let map = self.impls_by_trait.entry(*trait_).or_default();
123116
for (fp, impls) in other_map {
124117
let vec = map.entry(*fp).or_default();
125118
vec.extend(impls);
126-
vec.sort();
127-
vec.dedup();
128119
}
129120
}
130121
}

0 commit comments

Comments
 (0)