diff options
author | Sadie Powell <sadie@witchery.services> | 2023-10-10 21:14:50 +0100 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2023-10-11 15:51:52 +0100 |
commit | a3241065c55fd2a69e8793b89a5d0b1a957b3fd0 (patch) | |
tree | 82f80ce2f3bbbdc1c1ef05fe611093cf0b34eab6 /modules/commands/help.cpp | |
parent | dc371aad6d059dbf7f30f6878c680532bedd4146 (diff) |
Start migrating to range-based for loops.
Diffstat (limited to 'modules/commands/help.cpp')
-rw-r--r-- | modules/commands/help.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/modules/commands/help.cpp b/modules/commands/help.cpp index 31b27e0ea..071161fcd 100644 --- a/modules/commands/help.cpp +++ b/modules/commands/help.cpp @@ -17,9 +17,8 @@ class CommandHelp : public Command static CommandGroup *FindGroup(const Anope::string &name) { - for (unsigned i = 0; i < Config->CommandGroups.size(); ++i) + for (auto &gr : Config->CommandGroups) { - CommandGroup &gr = Config->CommandGroups[i]; if (gr.name == name) return &gr; } @@ -56,18 +55,15 @@ class CommandHelp : public Command if (all) source.Reply(_("All available commands for \002%s\002:"), source.service->nick.c_str()); - for (CommandInfo::map::const_iterator it = map.begin(), it_end = map.end(); it != it_end; ++it) + for (const auto &[c_name, info] : map) { - const Anope::string &c_name = it->first; - const CommandInfo &info = it->second; - if (info.hide) continue; // Smaller command exists Anope::string cmd; spacesepstream(c_name).GetToken(cmd, 0); - if (cmd != it->first && map.count(cmd)) + if (cmd != c_name && map.count(cmd)) continue; ServiceReference<Command> c("Command", info.name); @@ -95,18 +91,14 @@ class CommandHelp : public Command } - for (GroupInfo::iterator it = groups.begin(), it_end = groups.end(); it != it_end; ++it) + for (auto &[gr, cmds] : groups) { - CommandGroup *gr = it->first; - source.Reply(" "); source.Reply("%s", gr->description.c_str()); Anope::string buf; - for (std::list<Anope::string>::iterator it2 = it->second.begin(), it2_end = it->second.end(); it2 != it2_end; ++it2) + for (const auto &c_name : cmds) { - const Anope::string &c_name = *it2; - buf += ", " + c_name; if (buf.length() > help_wrap_len) |