Speed up Pool::match for common case
parent
c97720c607
commit
6f77df296a
|
@ -339,6 +339,17 @@ class Pool
|
||||||
if (is_array($candidate)) {
|
if (is_array($candidate)) {
|
||||||
$candidateName = $candidate['name'];
|
$candidateName = $candidate['name'];
|
||||||
$candidateVersion = $candidate['version'];
|
$candidateVersion = $candidate['version'];
|
||||||
|
} else {
|
||||||
|
// handle object packages
|
||||||
|
$candidateName = $candidate->getName();
|
||||||
|
$candidateVersion = $candidate->getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($candidateName === $name) {
|
||||||
|
return $constraint->matches(new VersionConstraint('==', $candidateVersion)) ? self::MATCH : self::MATCH_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($candidate)) {
|
||||||
$provides = isset($candidate['provide'])
|
$provides = isset($candidate['provide'])
|
||||||
? $this->versionParser->parseLinks($candidateName, $candidateVersion, 'provides', $candidate['provide'])
|
? $this->versionParser->parseLinks($candidateName, $candidateVersion, 'provides', $candidate['provide'])
|
||||||
: array();
|
: array();
|
||||||
|
@ -346,17 +357,10 @@ class Pool
|
||||||
? $this->versionParser->parseLinks($candidateName, $candidateVersion, 'replaces', $candidate['replace'])
|
? $this->versionParser->parseLinks($candidateName, $candidateVersion, 'replaces', $candidate['replace'])
|
||||||
: array();
|
: array();
|
||||||
} else {
|
} else {
|
||||||
// handle object packages
|
|
||||||
$candidateName = $candidate->getName();
|
|
||||||
$candidateVersion = $candidate->getVersion();
|
|
||||||
$provides = $candidate->getProvides();
|
$provides = $candidate->getProvides();
|
||||||
$replaces = $candidate->getReplaces();
|
$replaces = $candidate->getReplaces();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($candidateName === $name) {
|
|
||||||
return $constraint->matches(new VersionConstraint('==', $candidateVersion)) ? self::MATCH : self::MATCH_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($provides as $link) {
|
foreach ($provides as $link) {
|
||||||
if ($link->getTarget() === $name && $constraint->matches($link->getConstraint())) {
|
if ($link->getTarget() === $name && $constraint->matches($link->getConstraint())) {
|
||||||
return self::MATCH_PROVIDE;
|
return self::MATCH_PROVIDE;
|
||||||
|
|
Loading…
Reference in New Issue