From 3c455a8511f8c72552afb6ebe35a8e7c9b9af979 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 30 Jul 2022 17:21:47 +0100 Subject: Modernize various minor legacy C++isms. --- src/cull.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/cull.cpp') diff --git a/src/cull.cpp b/src/cull.cpp index 4810eee84..757fbb99f 100644 --- a/src/cull.cpp +++ b/src/cull.cpp @@ -60,7 +60,7 @@ Cullable::Result Cullable::Cull() typeid(*this).name(), static_cast(this)); } #endif - return Result(); + return {}; } void CullList::Apply() @@ -77,12 +77,12 @@ void CullList::Apply() } working.clear(); } + std::set gone; std::vector queue; queue.reserve(list.size() + 32); - for(unsigned int i=0; i < list.size(); i++) + for (auto& c : list) { - Cullable* c = list[i]; if (gone.insert(c).second) { #ifdef INSPIRCD_ENABLE_RTTI @@ -106,11 +106,10 @@ void CullList::Apply() } } list.clear(); - for(unsigned int i=0; i < queue.size(); i++) - { - Cullable* c = queue[i]; + + for (auto& c : queue) delete c; - } + if (!list.empty()) { ServerInstance->Logs.Debug("CULLLIST", "WARNING: Objects added to cull list in a destructor"); @@ -120,9 +119,7 @@ void CullList::Apply() void ActionList::Run() { - for(unsigned int i=0; i < list.size(); i++) - { - list[i]->Call(); - } + for (auto& action : list) + action->Call(); list.clear(); } -- cgit v1.3.1-10-gc9f91