]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Move some looping checks from size() to !empty()
authorFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 4 Feb 2014 16:54:49 +0000 (17:54 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 4 Feb 2014 16:54:49 +0000 (17:54 +0100)
src/ConfigOption.cc
src/DiskIO/DiskIOModule.cc
src/HttpHdrRange.cc
src/StoreFileSystem.cc
src/adaptation/Service.cc
src/adaptation/icap/ServiceRep.cc
src/errorpage.cc
src/esi/VarState.cc
src/store_dir.cc

index 92a5ede6afb855edc63b07cf3b171d7ab95ecaae..2b771479ee8abac07e48cfef351587babb5a9c37 100644 (file)
@@ -35,7 +35,7 @@
 
 ConfigOptionVector::~ConfigOptionVector()
 {
-    while (options.size()) {
+    while (!options.empty()) {
         delete options.back();
         options.pop_back();
     }
index 0bc3278ac086a15dd19596b5251c360b81b0d805..c72d290b2423cda3c1f4121b16849221107ec1b3 100644 (file)
@@ -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();
index 950b968ca338e47a59ec1235d08ca44102cd238a..32d71f1fcf250e9e7d2fca5244525494737e4bcd 100644 (file)
@@ -283,7 +283,7 @@ HttpHdrRange::parseInit(const String * range_spec)
 
 HttpHdrRange::~HttpHdrRange()
 {
-    while (specs.size()) {
+    while (!specs.empty()) {
         delete specs.back();
         specs.pop_back();
     }
index 7b3497ed22337c93d2263fb1716fccd6c9b28d94..ad91f70802a3539c7b2f48f277c7e60d4448274c 100644 (file)
@@ -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();
index 10f1e642e81c54e9d14a8e00fbcc73eb29057c81..8a54e85456782518e1410ec7e843ce1b7129754c 100644 (file)
@@ -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();
index ac295a767e916a0191652b98d7fdd2b725dd060f..95d2d68a6b57b41da5980d3c10ff69d43ac3be19 100644 (file)
@@ -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();
index 8fc1fb984fc41251db609147db150beed24b9c65..92ab11c91e369e52ed94cad083467b1da1fe5fe8 100644 (file)
@@ -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();
     }
index 9ac9fbb7947f78b0e084e8e483a0c6bee93c279b..67bb157e9cfd48d4d060bb7ddcec6b14ee4984e2 100644 (file)
@@ -167,7 +167,7 @@ ESIVarState::~ESIVarState()
 {
     freeResources();
 
-    while (variablesForCleanup.size()) {
+    while (!variablesForCleanup.empty()) {
         delete variablesForCleanup.back();
         variablesForCleanup.pop_back();
     }
index f135975560b0fa9a2cbc97c26da7701c05955b33..a20baa109f81706cb0ea1a749fbe057b2b0c2f6c 100644 (file)
@@ -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())