From 942fd2bcfd384a12c900999fe663202c87319a68 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 6 Apr 2021 20:06:18 +0100 Subject: Switch simple iterator loops to use range-based for loops. --- src/modules/m_ircv3_batch.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/modules/m_ircv3_batch.cpp') diff --git a/src/modules/m_ircv3_batch.cpp b/src/modules/m_ircv3_batch.cpp index a59519d1d..c41b9f395 100644 --- a/src/modules/m_ircv3_batch.cpp +++ b/src/modules/m_ircv3_batch.cpp @@ -108,12 +108,8 @@ class IRCv3::Batch::ManagerImpl : public Manager { // Set batchbits to 0 for all users in case we were reloaded and the previous, now meaningless, // batchbits are set on users - const UserManager::LocalList& users = ServerInstance->Users.GetLocalUsers(); - for (UserManager::LocalList::const_iterator i = users.begin(); i != users.end(); ++i) - { - LocalUser* const user = *i; + for (auto* user : ServerInstance->Users.GetLocalUsers()) batchbits.Unset(user); - } } void Shutdown() @@ -128,12 +124,11 @@ class IRCv3::Batch::ManagerImpl : public Manager const intptr_t bits = batchbits.Get(user); // User is quitting, remove them from all lists - for (BatchList::iterator i = active_batches.begin(); i != active_batches.end(); ++i) + for (const auto& batch : active_batches) { - Batch& batch = **i; // Check the bit first to avoid list scan in case they're not on the list - if ((bits & batch.GetBit()) != 0) - stdalgo::vector::swaperase(batch.batchinfo->users, user); + if ((bits & batch->GetBit()) != 0) + stdalgo::vector::swaperase(batch->batchinfo->users, user); } } @@ -169,9 +164,8 @@ class IRCv3::Batch::ManagerImpl : public Manager BatchInfo& batchinfo = *batch.batchinfo; // Send end batch message to all users who got the batch start message and unset bit so it can be reused - for (std::vector::const_iterator i = batchinfo.users.begin(); i != batchinfo.users.end(); ++i) + for (const auto& user : batchinfo.users) { - LocalUser* const user = *i; user->Send(batchinfo.endevent); batchbits.Set(user, batchbits.Get(user) & ~batch.GetBit()); } -- cgit v1.3.1-10-gc9f91