]> git.saurik.com Git - apt.git/commitdiff
Port TagIterator to correctly support ReMap (doh). cydia_1.1.28%b9
authorJay Freeman (saurik) <saurik@saurik.com>
Tue, 31 Jan 2017 13:53:50 +0000 (05:53 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Tue, 31 Jan 2017 13:53:50 +0000 (05:53 -0800)
apt-pkg/cacheiterators.h
apt-pkg/pkgcachegen.cc

index 3308f43dda3e3bf83094e312d82a90b74e1f5ca9..5fb416d79df09f27bbe1bd535e2d3f623374419e 100644 (file)
@@ -250,45 +250,30 @@ class pkgCache::VerIterator : public Iterator<Version, VerIterator> {
 };
                                                                        /*}}}*/
 // Tag Iterator                                                                /*{{{*/
-class pkgCache::TagIterator
-{
-   Tag *Tg;
-   pkgCache *Owner;
-
-   void _dummy();
-
-   public:
+class pkgCache::TagIterator : public Iterator<Tag, TagIterator> {
+       public:
+       inline Tag* OwnerPointer() const {
+               return (Owner != 0) ? Owner->TagP : 0;
+       }
 
    // Iteration
-   void operator ++(int) {if (Tg != Owner->TagP) Tg = Owner->TagP + Tg->NextTag;};
+   void operator ++(int) {if (S != Owner->TagP) S = Owner->TagP + S->NextTag;};
    inline void operator ++() {operator ++(0);};
-   inline bool end() const {return Tg == Owner->TagP?true:false;};
-   inline void operator =(const TagIterator &B) {Tg = B.Tg; Owner = B.Owner;};
 
    // Comparison
-   inline bool operator ==(const TagIterator &B) const {return Tg == B.Tg;};
-   inline bool operator !=(const TagIterator &B) const {return Tg != B.Tg;};
+   inline bool operator ==(const TagIterator &B) const {return S == B.S;};
+   inline bool operator !=(const TagIterator &B) const {return S != B.S;};
    int CompareTag(const TagIterator &B) const;
 
    // Accessors
-   inline Tag *operator ->() {return Tg;};
-   inline Tag const *operator ->() const {return Tg;};
-   inline Tag &operator *() {return *Tg;};
-   inline Tag const &operator *() const {return *Tg;};
-   inline operator Tag *() {return Tg == Owner->TagP?0:Tg;};
-   inline operator Tag const *() const {return Tg == Owner->TagP?0:Tg;};
-   inline pkgCache *Cache() {return Owner;};
-
-   inline const char *Name() const {return Owner->StrP + Tg->Name;};
-   inline unsigned long Index() const {return Tg - Owner->TagP;};
-
-   inline TagIterator() : Tg(0), Owner(0) {};
-   inline TagIterator(pkgCache &Owner,Tag *Trg = 0) : Tg(Trg),
-              Owner(&Owner)
-   {
-      if (Tg == 0)
-        Tg = Owner.TagP;
-   };
+   inline const char *Name() const {return Owner->StrP + S->Name;};
+   inline unsigned long Index() const {return S - Owner->TagP;};
+
+       inline TagIterator(pkgCache &Owner,Tag *Trg = 0) : Iterator<Tag, TagIterator>(Owner, Trg) {
+               if (S == 0)
+                       S = OwnerPointer();
+       }
+       inline TagIterator() : Iterator<Tag, TagIterator>() {}
 };
                                                                        /*}}}*/
 // Description Iterator                                                        /*{{{*/
index 8ee682db83f38a7e2e9cee8f8a43047d6bbef095..7152f04e2dce599f2efa7a423040a5391254877a 100644 (file)
@@ -175,6 +175,10 @@ void pkgCacheGenerator::ReMap(void const * const oldMap, void const * const newM
        i != Dynamic<pkgCache::VerIterator>::toReMap.end(); ++i)
       if (std::get<1>(seen.insert(*i)) == true)
         (*i)->ReMap(oldMap, newMap);
+   for (std::vector<pkgCache::TagIterator*>::const_iterator i = Dynamic<pkgCache::TagIterator>::toReMap.begin();
+       i != Dynamic<pkgCache::TagIterator>::toReMap.end(); ++i)
+      if (std::get<1>(seen.insert(*i)) == true)
+        (*i)->ReMap(oldMap, newMap);
    for (std::vector<pkgCache::DepIterator*>::const_iterator i = Dynamic<pkgCache::DepIterator>::toReMap.begin();
        i != Dynamic<pkgCache::DepIterator>::toReMap.end(); ++i)
        if (std::get<1>(seen.insert(*i)) == true)
@@ -1290,18 +1294,20 @@ bool pkgCacheGenerator::NewTag(pkgCache::VerIterator &Ver,
                                           unsigned int NameSize)
 {
    // Get a structure
-   unsigned long Tagg = AllocateInMap(sizeof(pkgCache::Tag));
-   if (Tagg == 0)
+   map_pointer_t const idxTag = AllocateInMap(sizeof(pkgCache::Tag));
+   if (unlikely(idxTag == 0))
       return false;
-   Cache.HeaderP->TagCount++;
    
    // Fill it in
-   pkgCache::TagIterator Tg(Cache,Cache.TagP + Tagg);
-   Tg->Name = WriteStringInMap(NameStart,NameSize);
-   if (Tg->Name == 0)
+   pkgCache::TagIterator Tg(Cache,Cache.TagP + idxTag);
+   map_pointer_t const idxName = WriteStringInMap(NameStart,NameSize);
+   if (idxName == 0)
       return false;
+   Tg->Name = idxName;
+
    Tg->NextTag = Ver->TagList;
    Ver->TagList = Tg.Index();
+   Cache.HeaderP->TagCount++;
    
    return true;
 }