* apt-pkg/cacheset.cc:
authorDavid Kalnischkies <kalnischkies@gmail.com>
Thu, 10 Jun 2010 11:09:23 +0000 (13:09 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Thu, 10 Jun 2010 11:09:23 +0000 (13:09 +0200)
  - get the candidate either from an already built depcache
    or use the policy which is a bit faster than depcache generation

apt-pkg/cachefile.h
apt-pkg/cacheset.cc
debian/changelog

index 1647aff..c68f06e 100644 (file)
 
 #include <apt-pkg/depcache.h>
 #include <apt-pkg/acquire.h>
+#include <apt-pkg/policy.h>
 #include <apt-pkg/sourcelist.h>
 
-class pkgPolicy;
-class pkgSourceList;
 class pkgCacheFile
 {
    protected:
@@ -65,6 +64,11 @@ class pkgCacheFile
    inline pkgPolicy* GetPolicy() { BuildPolicy(); return Policy; };
    inline pkgSourceList* GetSourceList() { BuildSourceList(); return SrcList; };
 
+   inline bool IsPkgCacheBuilt() const { return (Cache != NULL); };
+   inline bool IsDepCacheBuilt() const { return (DCache != NULL); };
+   inline bool IsPolicyBuilt() const { return (Policy != NULL); };
+   inline bool IsSrcListBuilt() const { return (SrcList != NULL); };
+
    pkgCacheFile();
    virtual ~pkgCacheFile();
 };
index 43ade4b..e91b569 100644 (file)
@@ -261,9 +261,14 @@ bool VersionSet::AddSelectedVersion(pkgCacheFile &Cache, VersionSet &verset,
 // getCandidateVer - Returns the candidate version of the given package        /*{{{*/
 pkgCache::VerIterator VersionSet::getCandidateVer(pkgCacheFile &Cache,
                pkgCache::PkgIterator const &Pkg, bool const &AllowError) {
-       if (unlikely(Cache.BuildDepCache() == false))
-               return pkgCache::VerIterator(*Cache);
-       pkgCache::VerIterator Cand = Cache[Pkg].CandidateVerIter(Cache);
+       pkgCache::VerIterator Cand;
+       if (Cache.IsDepCacheBuilt() == true)
+               Cand = Cache[Pkg].CandidateVerIter(Cache);
+       else {
+               if (unlikely(Cache.BuildPolicy() == false))
+                       return pkgCache::VerIterator(*Cache);
+               Cand = Cache.GetPolicy()->GetCandidateVer(Pkg);
+       }
        if (AllowError == false && Cand.end() == true)
                _error->Error(_("Can't select candidate version from package %s as it has no candidate"), Pkg.FullName(true).c_str());
        return Cand;
index f9638b7..8470a0d 100644 (file)
@@ -1,3 +1,11 @@
+apt (0.7.26~exp7) UNRELEASED; urgency=low
+
+  * apt-pkg/cacheset.cc:
+    - get the candidate either from an already built depcache
+      or use the policy which is a bit faster than depcache generation
+
+ -- David Kalnischkies <kalnischkies@gmail.com>  Thu, 10 Jun 2010 13:04:47 +0200
+
 apt (0.7.26~exp6) UNRELEASED; urgency=low
 
   [ Michael Vogt ]