summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2016-05-06 16:46:51 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2016-05-20 14:18:36 +0200
commit6dcae298f972eb20223838f0e1dc376c44bc9cc3 (patch)
tree2906652b0ed9f08dd5ab7473b475afda975bda72
parent43c71fad3a51d841132ba15a7a5930e1ee4126ed (diff)
edsp: use a limited scenario based on bool-array
Its more space and runtime efficient to use a boolean set instead of a CacheSet-based implementation. Git-Dch: Ignore
-rw-r--r--apt-pkg/edsp.cc16
-rw-r--r--apt-pkg/edsp.h3
-rw-r--r--cmdline/apt-internal-solver.cc7
3 files changed, 18 insertions, 8 deletions
diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc
index 6fd97845b..5e03cecaa 100644
--- a/apt-pkg/edsp.cc
+++ b/apt-pkg/edsp.cc
@@ -300,7 +300,7 @@ static void WriteScenarioLimitedDependency(FILE* output,
}
static bool WriteScenarioLimitedDependency(FileFd &output,
pkgCache::VerIterator const &Ver,
- APT::PackageSet const &pkgset)
+ std::vector<bool> const &pkgset)
{
std::array<std::string, _count(DepMap)> dependencies;
bool orGroup = false;
@@ -310,12 +310,12 @@ static bool WriteScenarioLimitedDependency(FileFd &output,
continue;
if (orGroup == false)
{
- if (pkgset.find(Dep.TargetPkg()) == pkgset.end())
+ if (pkgset[Dep.TargetPkg()->ID] == false)
continue;
if (dependencies[Dep->Type].empty() == false)
dependencies[Dep->Type].append(", ");
}
- else if (pkgset.find(Dep.TargetPkg()) == pkgset.end())
+ else if (pkgset[Dep.TargetPkg()->ID] == false)
{
if ((Dep->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or)
continue;
@@ -343,7 +343,7 @@ static bool WriteScenarioLimitedDependency(FileFd &output,
{
if (Prv.IsMultiArchImplicit() == true)
continue;
- if (pkgset.find(Prv.ParentPkg()) == pkgset.end())
+ if (pkgset[Prv.ParentPkg()->ID] == false)
continue;
if (provides.empty() == false)
provides.append(", ");
@@ -449,14 +449,17 @@ bool EDSP::WriteLimitedScenario(pkgDepCache &Cache, FILE* output,
return true;
}
bool EDSP::WriteLimitedScenario(pkgDepCache &Cache, FileFd &output,
- APT::PackageSet const &pkgset,
+ std::vector<bool> const &pkgset,
OpProgress *Progress)
{
if (Progress != NULL)
Progress->SubProgress(Cache.Head().VersionCount, _("Send scenario to solver"));
unsigned long p = 0;
bool Okay = output.Failed() == false;
- for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end() && likely(Okay); ++Pkg, ++p)
+ for (auto Pkg = Cache.PkgBegin(); Pkg.end() == false && likely(Okay); ++Pkg, ++p)
+ {
+ if (pkgset[Pkg->ID] == false)
+ continue;
for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false && likely(Okay); ++Ver)
{
if (SkipUnavailableVersions(Cache, Pkg, Ver))
@@ -467,6 +470,7 @@ bool EDSP::WriteLimitedScenario(pkgDepCache &Cache, FileFd &output,
if (Progress != NULL && p % 100 == 0)
Progress->Progress(p);
}
+ }
if (Progress != NULL)
Progress->Done();
return Okay;
diff --git a/apt-pkg/edsp.h b/apt-pkg/edsp.h
index 9e92e59d9..347304390 100644
--- a/apt-pkg/edsp.h
+++ b/apt-pkg/edsp.h
@@ -18,6 +18,7 @@
#include <list>
#include <string>
+#include <vector>
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/depcache.h>
@@ -98,7 +99,7 @@ namespace EDSP /*{{{*/
* \return true if universe was composed successfully, otherwise false
*/
bool WriteLimitedScenario(pkgDepCache &Cache, FileFd &output,
- APT::PackageSet const &pkgset,
+ std::vector<bool> const &pkgset,
OpProgress *Progress = NULL);
bool WriteLimitedScenario(pkgDepCache &Cache, FILE* output,
APT::PackageSet const &pkgset,
diff --git a/cmdline/apt-internal-solver.cc b/cmdline/apt-internal-solver.cc
index fa54657c0..12f4d6f93 100644
--- a/cmdline/apt-internal-solver.cc
+++ b/cmdline/apt-internal-solver.cc
@@ -88,7 +88,12 @@ int main(int argc,const char *argv[]) /*{{{*/
if (pkgset.empty() == true)
EDSP::WriteScenario(CacheFile, output);
else
- EDSP::WriteLimitedScenario(CacheFile, output, pkgset);
+ {
+ std::vector<bool> pkgvec(CacheFile->Head().PackageCount, false);
+ for (auto const &p: pkgset)
+ pkgvec[p->ID] = true;
+ EDSP::WriteLimitedScenario(CacheFile, output, pkgvec);
+ }
output.Close();
_error->DumpErrors(std::cerr);
return 0;