From 2d6d47b489d733ca3c29fc2f963d424029fcb929 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 11 Nov 2020 02:25:06 +0000 Subject: Add stdalgo::equal_range and switch more stuff to iterator_range. --- src/mode.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/mode.cpp') diff --git a/src/mode.cpp b/src/mode.cpp index 46dd502e0..64f844e28 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -297,10 +297,8 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode } // Ask mode watchers whether this mode change is OK - std::pair itpair = modewatchermap.equal_range(mh->name); - for (ModeWatcherMap::iterator i = itpair.first; i != itpair.second; ++i) + for (const auto& [_, mw] : stdalgo::equal_range(modewatchermap, mh->name)) { - ModeWatcher* mw = i->second; if (mw->GetModeType() == type) { if (!mw->BeforeMode(user, targetuser, chan, parameter, adding)) @@ -337,10 +335,8 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode if (ma != MODEACTION_ALLOW) return ma; - itpair = modewatchermap.equal_range(mh->name); - for (ModeWatcherMap::iterator i = itpair.first; i != itpair.second; ++i) + for (const auto& [_, mw] : stdalgo::equal_range(modewatchermap, mh->name)) { - ModeWatcher* mw = i->second; if (mw->GetModeType() == type) mw->AfterMode(user, targetuser, chan, parameter, adding); } @@ -502,10 +498,8 @@ void ModeParser::ShowListModeList(User* user, Channel* chan, ModeHandler* mh) bool display = true; // Ask mode watchers whether it's OK to show the list - std::pair itpair = modewatchermap.equal_range(mh->name); - for (ModeWatcherMap::iterator i = itpair.first; i != itpair.second; ++i) + for (const auto& [_, mw] : stdalgo::equal_range(modewatchermap, mh->name)) { - ModeWatcher* mw = i->second; if (mw->GetModeType() == MODETYPE_CHANNEL) { std::string dummyparam; -- cgit v1.3.1-10-gc9f91