Parcourir la source

Group packages in the same group together in the package list
so it is easier to find them later on as we have no "noice"
anymore between them.

David Kalnischkies il y a 16 ans
Parent
commit
c408e01e54
2 fichiers modifiés avec 22 ajouts et 21 suppressions
  1. 5 12
      apt-pkg/pkgcache.cc
  2. 17 9
      apt-pkg/pkgcachegen.cc

+ 5 - 12
apt-pkg/pkgcache.cc

@@ -343,24 +343,17 @@ pkgCache::PkgIterator pkgCache::GrpIterator::FindPkg(string Arch) {
 // GrpIterator::NextPkg - Locate the next package in the group		/*{{{*/
 // ---------------------------------------------------------------------
 /* Returns an End-Pointer on error, pointer to the package otherwise.
-   We can't simply ++ to the next as the list of packages includes
-   "package noise" (= packages with the same hash value but different name) */
+   We can't simply ++ to the next as the next package of the last will
+   be from a different group (with the same hash value) */
 pkgCache::PkgIterator pkgCache::GrpIterator::NextPkg(pkgCache::PkgIterator const &LastPkg) {
 	if (unlikely(IsGood() == false || S->FirstPackage == 0 ||
 	    LastPkg.end() == true))
 		return PkgIterator(*Owner, 0);
 
-	// Iterate over the list to find the next package
-	pkgCache::Package *Pkg = Owner->PkgP + LastPkg.Index();
-	Pkg = Owner->PkgP + Pkg->NextPackage;
-	for (; Pkg != Owner->PkgP; Pkg = Owner->PkgP + Pkg->NextPackage) {
-		if (S->Name == Pkg->Name)
-			return PkgIterator(*Owner, Pkg);
-		if ((Owner->PkgP + S->LastPackage) == Pkg)
-			break;
-	}
+	if (S->LastPackage == LastPkg.Index())
+		return PkgIterator(*Owner, 0);
 
-	return PkgIterator(*Owner, 0);
+	return PkgIterator(*Owner, Owner->PkgP + LastPkg->NextPackage);
 }
 									/*}}}*/
 // GrpIterator::operator ++ - Postfix incr				/*{{{*/

+ 17 - 9
apt-pkg/pkgcachegen.cc

@@ -379,15 +379,23 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const string &Name
       return false;
    Pkg = pkgCache::PkgIterator(Cache,Cache.PkgP + Package);
 
-   // Insert it into the hash table
-   unsigned long const Hash = Cache.Hash(Name);
-   Pkg->NextPackage = Cache.HeaderP->PkgHashTable[Hash];
-   Cache.HeaderP->PkgHashTable[Hash] = Package;
-
-   // remember the packages in the group
-   Grp->FirstPackage = Package;
-   if (Grp->LastPackage == 0)
-      Grp->LastPackage = Package;
+   // Insert the package into our package list
+   if (Grp->FirstPackage == 0) // the group is new
+   {
+      // Insert it into the hash table
+      unsigned long const Hash = Cache.Hash(Name);
+      Pkg->NextPackage = Cache.HeaderP->PkgHashTable[Hash];
+      Cache.HeaderP->PkgHashTable[Hash] = Package;
+      Grp->FirstPackage = Package;
+   }
+   else // Group the Packages together
+   {
+      // this package is the new last package
+      pkgCache::PkgIterator LastPkg(Cache, Cache.PkgP + Grp->LastPackage);
+      Pkg->NextPackage = LastPkg->NextPackage;
+      LastPkg->NextPackage = Package;
+   }
+   Grp->LastPackage = Package;
 
    // Set the name, arch and the ID
    Pkg->Name = Grp->Name;