]> git.saurik.com Git - apt.git/blobdiff - apt-private/private-cacheset.h
use https instead of git for Vcs-Git
[apt.git] / apt-private / private-cacheset.h
index 2b452ab7d88170438d9825c8e87c849a015210a9..4a43155febbdd2142fd60d91af45c0e6681d4ebb 100644 (file)
 
 class OpProgress;
 
 
 class OpProgress;
 
-struct APT_PUBLIC VersionSortDescriptionLocality                       /*{{{*/
+class VerIteratorWithCaching
 {
 {
-   bool operator () (const pkgCache::VerIterator &v_lhs,
-        const pkgCache::VerIterator &v_rhs)
+   const pkgCache::VerIterator iter;
+   const pkgCache::DescFile * descFile;
+public:
+   VerIteratorWithCaching(const pkgCache::VerIterator& iter) :
+      iter(iter),
+      descFile(iter->DescriptionList != 0
+        ? (const pkgCache::DescFile *) iter.TranslatedDescription().FileList()
+        : nullptr)
+   {}
+   const pkgCache::DescFile * CachedDescFile() const { return descFile; }
+   operator pkgCache::VerIterator() const { return iter; }
+};
+
+struct VersionSortDescriptionLocality                                  /*{{{*/
+{
+   bool operator () (const VerIteratorWithCaching &v_lhs,
+        const VerIteratorWithCaching &v_rhs)
    {
    {
-      pkgCache::DescFile const *A = nullptr;
-      pkgCache::DescFile const *B = nullptr;
-      if (v_lhs->DescriptionList != 0)
-        A = v_lhs.TranslatedDescription().FileList();
-      if (v_rhs->DescriptionList != 0)
-        B = v_rhs.TranslatedDescription().FileList();
+      pkgCache::DescFile const *A = v_lhs.CachedDescFile();
+      pkgCache::DescFile const *B = v_rhs.CachedDescFile();
 
       if (A == nullptr && B == nullptr)
         return false;
 
       if (A == nullptr && B == nullptr)
         return false;
@@ -45,7 +56,7 @@ struct APT_PUBLIC VersionSortDescriptionLocality                      /*{{{*/
                                                                        /*}}}*/
 // sorted by locality which makes iterating much faster
 typedef APT::VersionContainer<
                                                                        /*}}}*/
 // sorted by locality which makes iterating much faster
 typedef APT::VersionContainer<
-   std::set<pkgCache::VerIterator,
+   std::set<VerIteratorWithCaching,
             VersionSortDescriptionLocality> > LocalitySortedVersionSet;
 
 class Matcher {
             VersionSortDescriptionLocality> > LocalitySortedVersionSet;
 
 class Matcher {
@@ -65,7 +76,7 @@ bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
 
 
 // CacheSetHelper saving virtual packages                              /*{{{*/
 
 
 // CacheSetHelper saving virtual packages                              /*{{{*/
-class APT_PUBLIC CacheSetHelperVirtuals: public APT::CacheSetHelper {
+class CacheSetHelperVirtuals: public APT::CacheSetHelper {
 public:
    APT::PackageSet virtualPkgs;
 
 public:
    APT::PackageSet virtualPkgs;
 
@@ -78,7 +89,7 @@ public:
                                                                        /*}}}*/
 
 // CacheSetHelperAPTGet - responsible for message telling from the CacheSets/*{{{*/
                                                                        /*}}}*/
 
 // CacheSetHelperAPTGet - responsible for message telling from the CacheSets/*{{{*/
-class APT_PUBLIC CacheSetHelperAPTGet : public APT::CacheSetHelper {
+class CacheSetHelperAPTGet : public APT::CacheSetHelper {
        /** \brief stream message should be printed to */
        std::ostream &out;
        /** \brief were things like Task or RegEx used to select packages? */
        /** \brief stream message should be printed to */
        std::ostream &out;
        /** \brief were things like Task or RegEx used to select packages? */
@@ -89,7 +100,7 @@ class APT_PUBLIC CacheSetHelperAPTGet : public APT::CacheSetHelper {
 public:
        std::list<std::pair<pkgCache::VerIterator, std::string> > selectedByRelease;
 
 public:
        std::list<std::pair<pkgCache::VerIterator, std::string> > selectedByRelease;
 
-       CacheSetHelperAPTGet(std::ostream &out);
+       explicit CacheSetHelperAPTGet(std::ostream &out);
 
        virtual void showTaskSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) APT_OVERRIDE;
         virtual void showFnmatchSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) APT_OVERRIDE;
 
        virtual void showTaskSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) APT_OVERRIDE;
         virtual void showFnmatchSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) APT_OVERRIDE;