1
0
Fork 0

Create lookup table for installed packages in only one place

pull/667/head
Nils Adermann 2012-04-27 17:50:53 +02:00
parent 5daeacf0ac
commit f4ae88a5d6
1 changed files with 17 additions and 11 deletions

View File

@ -35,6 +35,8 @@ class Solver
protected $decisionMap;
protected $installedMap;
protected $installedPackages;
protected $packageToFeatureRule = array();
public function __construct(PolicyInterface $policy, Pool $pool, RepositoryInterface $installed)
@ -667,14 +669,20 @@ class Solver
}
}
protected function setupInstalledMap()
{
$this->installedPackages = $this->installed->getPackages();
$this->installedMap = array();
foreach ($this->installedPackages as $package) {
$this->installedMap[$package->getId()] = $package;
}
}
public function solve(Request $request)
{
$this->jobs = $request->getJobs();
$installedPackages = $this->installed->getPackages();
$this->installedMap = array();
foreach ($installedPackages as $package) {
$this->installedMap[$package->getId()] = $package;
}
$this->setupInstalledMap();
if (version_compare(PHP_VERSION, '5.3.4', '>=')) {
$this->decisionMap = new \SplFixedArray($this->pool->getMaxId() + 1);
@ -695,18 +703,18 @@ class Solver
switch ($job['cmd']) {
case 'update-all':
foreach ($installedPackages as $package) {
foreach ($this->installedMap as $package) {
$this->updateMap[$package->getId()] = true;
}
break;
}
}
foreach ($installedPackages as $package) {
foreach ($this->installedMap as $package) {
$this->addRulesForPackage($package);
}
foreach ($installedPackages as $package) {
foreach ($this->installedMap as $package) {
$this->addRulesForUpdatePackages($package);
}
@ -724,7 +732,7 @@ class Solver
// solver_addrpmrulesforweak(solv, &addedmap);
foreach ($installedPackages as $package) {
foreach ($this->installedMap as $package) {
$updates = $this->policy->findUpdatePackages($this, $this->pool, $this->installedMap, $package);
$rule = $this->createUpdateRule($package, $updates, Rule::RULE_INTERNAL_ALLOW_UPDATE, (string) $package);
@ -1467,8 +1475,6 @@ class Solver
$minimizationSteps = 0;
$installedPos = 0;
$this->installedPackages = $this->installed->getPackages();
while (true) {
if (1 === $level) {