Skip to content

Commit

Permalink
Avoid visiting packages more than once in checkPacksRec.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-ludwig committed May 3, 2024
1 parent 8b91535 commit f622afd
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions source/dub/project.d
Original file line number Diff line number Diff line change
Expand Up @@ -887,15 +887,19 @@ class Project {
}

// check for conflicts (packages missing in the final configuration graph)
void checkPacksRec(in Package pack) {
auto pc = pack.name in ret;
enforce(pc !is null, "Could not resolve configuration for package "~pack.name);
foreach (p, dep; pack.getDependencies(*pc)) {
auto visited = new bool[](package_list.length);
void checkPacksRec(size_t pack_idx) {
if (visited[pack_idx]) return;
visited[pack_idx] = true;
auto pname = package_names[pack_idx];
auto pc = pname in ret;
enforce(pc !is null, "Could not resolve configuration for package "~pname);
foreach (p, dep; package_list[pack_idx].getDependencies(*pc)) {
auto deppack = getDependency(p, dep.optional);
if (deppack) checkPacksRec(deppack);
if (deppack) checkPacksRec(package_list.countUntil(deppack));
}
}
checkPacksRec(m_rootPackage);
checkPacksRec(0);

return ret;
}
Expand Down

0 comments on commit f622afd

Please sign in to comment.