1
0
Fork 0

Simplify branch handling code

pull/779/head
Nils Adermann 2012-06-06 15:55:30 +02:00
parent 76f8642feb
commit 12abff8b4c
1 changed files with 6 additions and 11 deletions

View File

@ -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);