1
0
Fork 0

Cache in VersionConstraint

pull/2436/head
Alexey Kupershtokh 2013-11-20 10:14:44 +07:00
parent a537594e59
commit 0e2959cc32
1 changed files with 16 additions and 1 deletions

View File

@ -60,12 +60,27 @@ class VersionConstraint extends SpecificConstraint
return version_compare($a, $b, $operator); return version_compare($a, $b, $operator);
} }
public function matchSpecific(VersionConstraint $provider, $compareBranches = false)
{
static $c = array();
if (isset($c[$this->operator][$this->version][$provider->operator][$provider->version][$compareBranches])) {
//if ($c[$this->operator][$this->version][$provider->operator][$provider->version][$compareBranches] !=
// $this->_matchSpecific($provider, $compareBranches)) {
// throw new \Exception('Broken cache');
//}
return $c[$this->operator][$this->version][$provider->operator][$provider->version][$compareBranches];
}
return $c[$this->operator][$this->version][$provider->operator][$provider->version][$compareBranches] =
$this->_matchSpecific($provider, $compareBranches);
}
/** /**
* @param VersionConstraint $provider * @param VersionConstraint $provider
* @param bool $compareBranches * @param bool $compareBranches
* @return bool * @return bool
*/ */
public function matchSpecific(VersionConstraint $provider, $compareBranches = false) public function _matchSpecific(VersionConstraint $provider, $compareBranches = false)
{ {
$noEqualOp = str_replace('=', '', $this->operator); $noEqualOp = str_replace('=', '', $this->operator);
$providerNoEqualOp = str_replace('=', '', $provider->operator); $providerNoEqualOp = str_replace('=', '', $provider->operator);