From: Francesco Chemolli Date: Tue, 4 Feb 2014 16:54:49 +0000 (+0100) Subject: Move some looping checks from size() to !empty() X-Git-Tag: SQUID_3_5_0_1~379^2~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=385acf91ad5aeb2d171ab1974b8332e542119a58;p=thirdparty%2Fsquid.git Move some looping checks from size() to !empty() --- diff --git a/src/ConfigOption.cc b/src/ConfigOption.cc index 92a5ede6af..2b771479ee 100644 --- a/src/ConfigOption.cc +++ b/src/ConfigOption.cc @@ -35,7 +35,7 @@ ConfigOptionVector::~ConfigOptionVector() { - while (options.size()) { + while (!options.empty()) { delete options.back(); options.pop_back(); } diff --git a/src/DiskIO/DiskIOModule.cc b/src/DiskIO/DiskIOModule.cc index 0bc3278ac0..c72d290b24 100644 --- a/src/DiskIO/DiskIOModule.cc +++ b/src/DiskIO/DiskIOModule.cc @@ -92,7 +92,8 @@ DiskIOModule::GetModules() void DiskIOModule::FreeAllModules() { - while (GetModules().size()) { + // TODO fix antipattern: walk the vector and then clear in one go + while (!GetModules().empty()) { DiskIOModule *fs = GetModules().back(); GetModules().pop_back(); fs->gracefulShutdown(); diff --git a/src/HttpHdrRange.cc b/src/HttpHdrRange.cc index 950b968ca3..32d71f1fcf 100644 --- a/src/HttpHdrRange.cc +++ b/src/HttpHdrRange.cc @@ -283,7 +283,7 @@ HttpHdrRange::parseInit(const String * range_spec) HttpHdrRange::~HttpHdrRange() { - while (specs.size()) { + while (!specs.empty()) { delete specs.back(); specs.pop_back(); } diff --git a/src/StoreFileSystem.cc b/src/StoreFileSystem.cc index 7b3497ed22..ad91f70802 100644 --- a/src/StoreFileSystem.cc +++ b/src/StoreFileSystem.cc @@ -87,7 +87,8 @@ StoreFileSystem::GetFileSystems() void StoreFileSystem::FreeAllFs() { - while (GetFileSystems().size()) { + //TODO fix antipattern: call for all filesystems and clear in one go. + while (!GetFileSystems().empty()) { StoreFileSystem *fs = GetFileSystems().back(); GetFileSystems().pop_back(); fs->done(); diff --git a/src/adaptation/Service.cc b/src/adaptation/Service.cc index 10f1e642e8..8a54e85456 100644 --- a/src/adaptation/Service.cc +++ b/src/adaptation/Service.cc @@ -71,6 +71,7 @@ Adaptation::FindService(const Service::Id& key) void Adaptation::DetachServices() { + // TODO fix antipattern: walk the vector and then clear in one go while (!AllServices().empty()) { AllServices().back()->detach(); AllServices().pop_back(); diff --git a/src/adaptation/icap/ServiceRep.cc b/src/adaptation/icap/ServiceRep.cc index ac295a767e..95d2d68a6b 100644 --- a/src/adaptation/icap/ServiceRep.cc +++ b/src/adaptation/icap/ServiceRep.cc @@ -374,6 +374,7 @@ void Adaptation::Icap::ServiceRep::noteTimeToNotify() Pointer us = NULL; + // TODO fix antipattern: walk the vector and then clear in one go while (!theClients.empty()) { Client i = theClients.back(); theClients.pop_back(); diff --git a/src/errorpage.cc b/src/errorpage.cc index 8fc1fb984f..92ab11c91e 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -247,7 +247,8 @@ errorClean(void) safe_free(error_text); } - while (ErrorDynamicPages.size()) { + //TODO fix entipattern: destroy pages and then clear in one go + while (!ErrorDynamicPages.empty()) { errorDynamicPageInfoDestroy(ErrorDynamicPages.back()); ErrorDynamicPages.pop_back(); } diff --git a/src/esi/VarState.cc b/src/esi/VarState.cc index 9ac9fbb794..67bb157e9c 100644 --- a/src/esi/VarState.cc +++ b/src/esi/VarState.cc @@ -167,7 +167,7 @@ ESIVarState::~ESIVarState() { freeResources(); - while (variablesForCleanup.size()) { + while (!variablesForCleanup.empty()) { delete variablesForCleanup.back(); variablesForCleanup.pop_back(); } diff --git a/src/store_dir.cc b/src/store_dir.cc index f135975560..a20baa109f 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -1370,7 +1370,7 @@ StoreSearchHashIndex::next(void (aCallback)(void *), void *aCallbackData) bool StoreSearchHashIndex::next() { - if (entries.size()) + if (!entries.empty()) entries.pop_back(); while (!isDone() && !entries.size())