summaryrefslogtreecommitdiff
path: root/apt-pkg/pkgcachegen.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2010-03-30 12:39:33 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2010-03-30 12:39:33 +0200
commitc408e01e546e641a0906f188ca6bb924a2f17b40 (patch)
tree19e3017200594d6d6ae0b3e68a1e3cc04815596d /apt-pkg/pkgcachegen.cc
parent6dc60370a750334cb701386cfa4ef9719db9078a (diff)
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.
Diffstat (limited to 'apt-pkg/pkgcachegen.cc')
-rw-r--r--apt-pkg/pkgcachegen.cc26
1 files changed, 17 insertions, 9 deletions
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index 8187b3950..577e2f1d4 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/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;