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_geoclass.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/modules/m_geoclass.cpp') diff --git a/src/modules/m_geoclass.cpp b/src/modules/m_geoclass.cpp index bd08712e2..b3872c477 100644 --- a/src/modules/m_geoclass.cpp +++ b/src/modules/m_geoclass.cpp @@ -75,27 +75,22 @@ class ModuleGeoClass return MOD_RES_PASSTHRU; // Counter for the number of users in each country. - typedef std::map CountryCounts; - CountryCounts counts; + std::map counts; // Counter for the number of users in an unknown country. size_t unknown = 0; - const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers(); - for (UserManager::LocalList::const_iterator iter = list.begin(); iter != list.end(); ++iter) + for (auto* user : ServerInstance->Users.GetLocalUsers()) { - Geolocation::Location* location = geoapi ? geoapi->GetLocation(*iter) : NULL; + Geolocation::Location* location = geoapi ? geoapi->GetLocation(user) : nullptr; if (location) counts[location]++; else unknown++; } - for (CountryCounts::const_iterator iter = counts.begin(); iter != counts.end(); ++iter) - { - Geolocation::Location* location = iter->first; - stats.AddRow(RPL_STATSCOUNTRY, iter->second, location->GetCode(), location->GetName()); - } + for (const auto& [location, count] : counts) + stats.AddRow(RPL_STATSCOUNTRY, count, location->GetCode(), location->GetName()); if (unknown) stats.AddRow(RPL_STATSCOUNTRY, unknown, "*", "Unknown Country"); -- cgit v1.3.1-10-gc9f91