Skip to content

Commit

Permalink
Merge pull request #2866 from Geod24/mlang/Simplify1
Browse files Browse the repository at this point in the history
Trivial: Simplify PackageManager's loadInternal
  • Loading branch information
s-ludwig authored Feb 17, 2024
2 parents aa265e3 + 7630fdc commit ca4c2ce
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions source/dub/packagemanager.d
Original file line number Diff line number Diff line change
Expand Up @@ -1479,15 +1479,15 @@ package struct Location {

void loadInternal (NativePath pack_path, NativePath packageFile)
{
Package p;
import std.algorithm.searching : find;

// If the package has already been loaded, no need to re-load it.
auto rng = existing_packages.find!(pp => pp.path == pack_path);
if (!rng.empty)
return mgr.addPackages(this.fromPath, rng.front);

try {
foreach (pp; existing_packages)
if (pp.path == pack_path) {
p = pp;
break;
}
if (!p) p = mgr.load(pack_path, packageFile);
mgr.addPackages(this.fromPath, p);
mgr.addPackages(this.fromPath, mgr.load(pack_path, packageFile));
} catch (ConfigException exc) {
// Configy error message already include the path
logError("Invalid recipe for local package: %S", exc);
Expand Down

0 comments on commit ca4c2ce

Please sign in to comment.