diff options
| author | 2021-04-06 20:06:18 +0100 | |
|---|---|---|
| committer | 2021-04-07 10:36:11 +0100 | |
| commit | 942fd2bcfd384a12c900999fe663202c87319a68 (patch) | |
| tree | c2bad1906af27afbc3c7d96c3e5ca3c27c83f090 /src/users.cpp | |
| parent | Merge branch 'insp3' into master. (diff) | |
Switch simple iterator loops to use range-based for loops.
Diffstat (limited to 'src/users.cpp')
| -rw-r--r-- | src/users.cpp | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/users.cpp b/src/users.cpp index 4415a2f01..cafc4204c 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -472,10 +472,8 @@ void User::UnOper() /* Remove all oper only modes from the user when the deoper - Bug #466*/ Modes::ChangeList changelist; - const ModeParser::ModeHandlerMap& usermodes = ServerInstance->Modes.GetModes(MODETYPE_USER); - for (ModeParser::ModeHandlerMap::const_iterator i = usermodes.begin(); i != usermodes.end(); ++i) + for (const auto& [_, mh] : ServerInstance->Modes.GetModes(MODETYPE_USER)) { - ModeHandler* mh = i->second; if (mh->NeedsOper()) changelist.push_remove(mh); } @@ -933,13 +931,11 @@ void User::ForEachNeighbor(ForEachNeighborHandler& handler, bool include_self) } // Now consider the real neighbors - for (IncludeChanList::const_iterator i = include_chans.begin(); i != include_chans.end(); ++i) + for (const auto* memb : include_chans) { - Channel* chan = (*i)->chan; - const Channel::MemberMap& userlist = chan->GetUsers(); - for (Channel::MemberMap::const_iterator j = userlist.begin(); j != userlist.end(); ++j) + for (const auto& [user, _] : memb->chan->GetUsers()) { - LocalUser* curr = IS_LOCAL(j->first); + LocalUser* curr = IS_LOCAL(user); // User not yet visited? if ((curr) && (curr->already_sent != newid)) { @@ -970,13 +966,9 @@ void User::WriteRemoteNumeric(const Numeric::Numeric& numeric) */ bool User::SharesChannelWith(User *other) { - /* Outer loop */ - for (User::ChanList::iterator i = this->chans.begin(); i != this->chans.end(); ++i) + for (const auto* memb : chans) { - /* Eliminate the inner loop (which used to be ~equal in size to the outer loop) - * by replacing it with a map::find which *should* be more efficient - */ - if ((*i)->chan->HasUser(other)) + if (memb->chan->HasUser(other)) return true; } return false; |
