summaryrefslogtreecommitdiff
path: root/cmdline/apt-cache.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-11-07 19:18:21 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2014-11-08 14:29:25 +0100
commit32ab4bd05cb298f6bf1f9574f5b20570beaae429 (patch)
treed35f6a68c354c955a8407c1b4004570b14a8a815 /cmdline/apt-cache.cc
parentfa5404ab01bdf06eaf147d9f133139e6c89b906a (diff)
guard pkg/grp hashtable creation changes
The change itself is no problem ABI wise, but the remove of the old undynamic hashtables is, so we bring it back for older abis and happily use the now available free space to backport more recent additions like the dynamic hashtable itself. Git-Dch: Ignore
Diffstat (limited to 'cmdline/apt-cache.cc')
-rw-r--r--cmdline/apt-cache.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
index 1bd75dfba..9bac45029 100644
--- a/cmdline/apt-cache.cc
+++ b/cmdline/apt-cache.cc
@@ -267,11 +267,14 @@ static bool DumpPackage(CommandLine &CmdL)
// ShowHashTableStats - Show stats about a hashtable /*{{{*/
// ---------------------------------------------------------------------
/* */
+static map_pointer_t PackageNext(pkgCache::Package const * const P) { return P->NextPackage; }
+static map_pointer_t GroupNext(pkgCache::Group const * const G) { return G->Next; }
template<class T>
static void ShowHashTableStats(std::string Type,
T *StartP,
map_pointer_t *Hashtable,
- unsigned long Size)
+ unsigned long Size,
+ map_pointer_t(*Next)(T const * const))
{
// hashtable stats for the HashTable
unsigned long NumBuckets = Size;
@@ -290,7 +293,7 @@ static void ShowHashTableStats(std::string Type,
}
++UsedBuckets;
unsigned long ThisBucketSize = 0;
- for (; P != StartP; P = StartP + P->Next)
+ for (; P != StartP; P = StartP + Next(P))
++ThisBucketSize;
Entries += ThisBucketSize;
LongestBucket = std::max(ThisBucketSize, LongestBucket);
@@ -447,13 +450,13 @@ static bool Stats(CommandLine &)
APT_CACHESIZE(VerFileCount, VerFileSz) +
APT_CACHESIZE(DescFileCount, DescFileSz) +
APT_CACHESIZE(ProvidesCount, ProvidesSz) +
- (2 * Cache->Head().HashTableSize * sizeof(map_id_t));
+ (2 * Cache->Head().GetHashTableSize() * sizeof(map_id_t));
cout << _("Total space accounted for: ") << SizeToStr(Total) << endl;
#undef APT_CACHESIZE
// hashtable stats
- ShowHashTableStats<pkgCache::Package>("PkgHashTable", Cache->PkgP, Cache->Head().PkgHashTable(), Cache->Head().HashTableSize);
- ShowHashTableStats<pkgCache::Group>("GrpHashTable", Cache->GrpP, Cache->Head().GrpHashTable(), Cache->Head().HashTableSize);
+ ShowHashTableStats<pkgCache::Package>("PkgHashTable", Cache->PkgP, Cache->Head().PkgHashTableP(), Cache->Head().GetHashTableSize(), PackageNext);
+ ShowHashTableStats<pkgCache::Group>("GrpHashTable", Cache->GrpP, Cache->Head().GrpHashTableP(), Cache->Head().GetHashTableSize(), GroupNext);
return true;
}