From 3707fd4faab3f2e2521263070b68fd0afaae2900 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 13 Jul 2015 23:10:53 +0200 Subject: avoid virtual in the iterators With a bit of trickery and the Curiously recurring template pattern we can free us from our use of virtual in the iterators were it is unneeded bloat as we never deal with pointers to iterators and similar such. Git-Dch: Ignore --- apt-pkg/pkgcache.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'apt-pkg/pkgcache.cc') diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index ae04bc699..aebbffe8b 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -411,7 +411,7 @@ pkgCache::PkgIterator pkgCache::GrpIterator::NextPkg(pkgCache::PkgIterator const // GrpIterator::operator ++ - Postfix incr /*{{{*/ // --------------------------------------------------------------------- /* This will advance to the next logical group in the hash table. */ -void pkgCache::GrpIterator::operator ++(int) +pkgCache::GrpIterator& pkgCache::GrpIterator::operator++() { // Follow the current links if (S != Owner->GrpP) @@ -423,12 +423,13 @@ void pkgCache::GrpIterator::operator ++(int) HashIndex++; S = Owner->GrpP + Owner->HeaderP->GrpHashTableP()[HashIndex]; } + return *this; } /*}}}*/ // PkgIterator::operator ++ - Postfix incr /*{{{*/ // --------------------------------------------------------------------- /* This will advance to the next logical package in the hash table. */ -void pkgCache::PkgIterator::operator ++(int) +pkgCache::PkgIterator& pkgCache::PkgIterator::operator ++() { // Follow the current links if (S != Owner->PkgP) @@ -440,6 +441,7 @@ void pkgCache::PkgIterator::operator ++(int) HashIndex++; S = Owner->PkgP + Owner->HeaderP->PkgHashTableP()[HashIndex]; } + return *this; } /*}}}*/ // PkgIterator::State - Check the State of the package /*{{{*/ @@ -685,7 +687,7 @@ void pkgCache::DepIterator::GlobOr(DepIterator &Start,DepIterator &End) for (bool LastOR = true; end() == false && LastOR == true;) { LastOR = (S->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or; - (*this)++; + ++(*this); if (LastOR == true) End = (*this); } -- cgit v1.2.3