Simplify branch handling code
parent
76f8642feb
commit
12abff8b4c
|
@ -19,6 +19,9 @@ use Composer\Repository\RepositoryInterface;
|
||||||
*/
|
*/
|
||||||
class Solver
|
class Solver
|
||||||
{
|
{
|
||||||
|
const BRANCH_LITERALS = 0;
|
||||||
|
const BRANCH_LEVEL = 1;
|
||||||
|
|
||||||
protected $policy;
|
protected $policy;
|
||||||
protected $pool;
|
protected $pool;
|
||||||
protected $installed;
|
protected $installed;
|
||||||
|
@ -245,13 +248,7 @@ class Solver
|
||||||
$this->propagateIndex = count($this->decisions);
|
$this->propagateIndex = count($this->decisions);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!empty($this->branches)) {
|
while (!empty($this->branches) && $this->branches[count($this->branches) - 1][self::BRANCH_LEVEL] >= $level) {
|
||||||
list($literals, $branchLevel) = $this->branches[count($this->branches) - 1];
|
|
||||||
|
|
||||||
if ($branchLevel < $level) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
array_pop($this->branches);
|
array_pop($this->branches);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -596,7 +593,6 @@ class Solver
|
||||||
|
|
||||||
$level = 1;
|
$level = 1;
|
||||||
$systemLevel = $level + 1;
|
$systemLevel = $level + 1;
|
||||||
$minimizationSteps = 0;
|
|
||||||
$installedPos = 0;
|
$installedPos = 0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -754,9 +750,8 @@ class Solver
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($lastLiteral) {
|
if ($lastLiteral) {
|
||||||
unset($this->branches[$lastBranchIndex][0][$lastBranchOffset]);
|
unset($this->branches[$lastBranchIndex][self::BRANCH_LITERALS][$lastBranchOffset]);
|
||||||
$this->branches[$lastBranchIndex][0] = array_values($this->branches[$lastBranchIndex][0]);
|
array_values($this->branches[$lastBranchIndex][self::BRANCH_LITERALS]);
|
||||||
$minimizationSteps++;
|
|
||||||
|
|
||||||
$level = $lastLevel;
|
$level = $lastLevel;
|
||||||
$this->revert($level);
|
$this->revert($level);
|
||||||
|
|
Loading…
Reference in New Issue