Skip to content

Commit

Permalink
Use CompilingMatcher in DefaultPolicy for performance reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
Toflar committed Sep 13, 2023
1 parent 5474dc9 commit f3aafb9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Composer/DependencyResolver/DefaultPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Composer\Package\AliasPackage;
use Composer\Package\BasePackage;
use Composer\Package\PackageInterface;
use Composer\Semver\CompilingMatcher;
use Composer\Semver\Constraint\Constraint;

/**
Expand Down Expand Up @@ -49,10 +50,12 @@ public function versionCompare(PackageInterface $a, PackageInterface $b, string
return BasePackage::$stabilities[$stabA] < BasePackage::$stabilities[$stabB];
}

$constraint = new Constraint($operator, $b->getVersion());
$version = new Constraint('==', $a->getVersion());
// TODO: Why is this not the case in CompilingMatcher?
if (false !== strpos($a->getVersion(), 'dev-') || false !== strpos($b->getVersion(), 'dev-')) {
return true;
}

return $constraint->matchSpecific($version, true);
return CompilingMatcher::match(new Constraint($operator, $b->getVersion()), Constraint::OP_EQ, $a->getVersion());
}

/**
Expand Down

0 comments on commit f3aafb9

Please sign in to comment.