From f78fb67f4b6a5673e497ba1aeb19568581173909 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 14 Mar 2017 11:35:41 +0100 Subject: Refactor to avoid loop/dangling gcc warnings Gbp-Dch: Ignore --- ftparchive/apt-ftparchive.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'ftparchive') diff --git a/ftparchive/apt-ftparchive.cc b/ftparchive/apt-ftparchive.cc index ab6f48d61..9c02e5b87 100644 --- a/ftparchive/apt-ftparchive.cc +++ b/ftparchive/apt-ftparchive.cc @@ -1002,7 +1002,7 @@ static bool Clean(CommandLine &CmdL) stable_sort(PkgList.begin(),PkgList.end(),PackageMap::SrcDBCompare()); string CacheDir = Setup.FindDir("Dir::CacheDir"); - + for (vector::iterator I = PkgList.begin(); I != PkgList.end(); ) { if(I->BinCacheDB != "") @@ -1016,15 +1016,11 @@ static bool Clean(CommandLine &CmdL) if (DB_SRC.Clean() == false) _error->DumpErrors(); - string CacheDB = I->BinCacheDB; - string SrcCacheDB = I->SrcCacheDB; - while(I != PkgList.end() && - I->BinCacheDB == CacheDB && - I->SrcCacheDB == SrcCacheDB) - ++I; + I = std::find_if(I, PkgList.end(), + [&](PackageMap const &PM) { return PM.BinCacheDB != I->BinCacheDB || PM.SrcCacheDB != I->SrcCacheDB; + }); } - return true; } /*}}}*/ -- cgit v1.2.3