Skip to content

Commit 1863aa2

Browse files
committed
Fix exponentiality in depend_on_deps_of_deps.
1 parent 4c1fa54 commit 1863aa2

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/cargo/core/compiler/job_queue.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> {
154154
let dependencies = cx.dep_targets(unit);
155155
let mut queue_deps = dependencies
156156
.iter()
157+
.cloned()
157158
.filter(|unit| {
158159
// Binaries aren't actually needed to *compile* tests, just to run
159160
// them, so we don't include this dependency edge in the job graph.
160161
!unit.target.is_test() || !unit.target.is_bin()
161162
})
162-
.cloned()
163163
.map(|dep| {
164164
// Handle the case here where our `unit -> dep` dependency may
165165
// only require the metadata, not the full compilation to
@@ -172,7 +172,7 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> {
172172
};
173173
(dep, artifact)
174174
})
175-
.collect::<Vec<_>>();
175+
.collect::<HashMap<_, _>>();
176176

177177
// This is somewhat tricky, but we may need to synthesize some
178178
// dependencies for this target if it requires full upstream
@@ -196,19 +196,18 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> {
196196
// `Metadata` propagate upwards `All` dependencies to anything that
197197
// transitively contains the `Metadata` edge.
198198
if unit.requires_upstream_objects() {
199-
for dep in dependencies.iter() {
199+
for dep in dependencies {
200200
depend_on_deps_of_deps(cx, &mut queue_deps, dep);
201201
}
202202

203203
fn depend_on_deps_of_deps<'a>(
204204
cx: &Context<'a, '_>,
205-
deps: &mut Vec<(Unit<'a>, Artifact)>,
206-
unit: &Unit<'a>,
205+
deps: &mut HashMap<Unit<'a>, Artifact>,
206+
unit: Unit<'a>,
207207
) {
208-
for dep in cx.dep_targets(unit) {
209-
if cx.only_requires_rmeta(unit, &dep) {
210-
deps.push((dep, Artifact::All));
211-
depend_on_deps_of_deps(cx, deps, &dep);
208+
for dep in cx.dep_targets(&unit) {
209+
if deps.insert(dep, Artifact::All).is_none() {
210+
depend_on_deps_of_deps(cx, deps, dep);
212211
}
213212
}
214213
}

0 commit comments

Comments
 (0)