Skip to content

Commit

Permalink
Merge pull request #2902 from atilaneves/speed-up-getPackageConfigs
Browse files Browse the repository at this point in the history
Speed up Package.getPackageConfigs

Signed-off-by: Nicholas Wilson <thewilsonator@users.noreply.github.com>
Merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
  • Loading branch information
dlang-bot authored Apr 20, 2024
2 parents b11e018 + efcda29 commit 2f918df
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions source/dub/dependency.d
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ struct PackageDependency {
this.spec = s;
}

int opCmp(in typeof(this) other) @safe const {
return name == other.name
? spec.opCmp(other.spec)
: name.opCmp(other.name);
}

/// Name of the referenced package.
PackageName name;

Expand Down
7 changes: 6 additions & 1 deletion source/dub/package_.d
Original file line number Diff line number Diff line change
Expand Up @@ -573,13 +573,18 @@ class Package {
// Left as package until the final API for this has been found
package auto getAllDependenciesRange()
const {
import std.algorithm: sort, uniq;
import std.array: array;
return
chain(
only(this.recipe.buildSettings.dependencies.byKeyValue),
this.recipe.configurations.map!(c => c.buildSettings.dependencies.byKeyValue)
)
.joiner()
.map!(d => PackageDependency(PackageName(d.key), d.value));
.map!(d => PackageDependency(PackageName(d.key), d.value))
.array
.sort
.uniq;
}


Expand Down
7 changes: 7 additions & 0 deletions source/dub/project.d
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,13 @@ class Project {

void determineDependencyConfigs(in Package p, string c)
{

// below we call createConfig for the main package if
// config.length is not zero. Carry on for that case,
// otherwise we've handle the pair (p, c) already
if(haveConfig(p.name, c) && !(config.length && p.name == m_rootPackage.name && config == c))
return;

string[][string] depconfigs;
foreach (d; p.getAllDependencies()) {
auto dp = getDependency(d.name.toString(), true);
Expand Down

0 comments on commit 2f918df

Please sign in to comment.