]> git.saurik.com Git - apt.git/commitdiff
edsp: use a limited scenario based on bool-array
authorDavid Kalnischkies <david@kalnischkies.de>
Fri, 6 May 2016 14:46:51 +0000 (16:46 +0200)
committerDavid Kalnischkies <david@kalnischkies.de>
Fri, 20 May 2016 12:18:36 +0000 (14:18 +0200)
Its more space and runtime efficient to use a boolean set instead of a
CacheSet-based implementation.

Git-Dch: Ignore

apt-pkg/edsp.cc
apt-pkg/edsp.h
cmdline/apt-internal-solver.cc

index 6fd97845bcf9f6fb568b0f36c9129294ce95d5ad..5e03cecaa9117c3fcdf8c38776084131d5aae8df 100644 (file)
@@ -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;
index 9e92e59d99534c298096801c3526634c3654f8e5..347304390ce76fd067df930d024e6209430e0144 100644 (file)
@@ -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,
index fa54657c0e0721c02b7a3b6a8b6ca688f53640c6..12f4d6f938198e36927946129e3549357c7cb597 100644 (file)
@@ -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;