[clang-tidy] convert several loops to range based ones

Found with modernize-loop-convert

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2020-01-31 20:09:15 -08:00
parent bc6eca2115
commit 15fa780c99
No known key found for this signature in database
GPG Key ID: 36D31CFA845F0E3B
3 changed files with 8 additions and 8 deletions

View File

@ -246,8 +246,8 @@ static CommandResult
PrintAvailableCommands(Response &r, const Partition &partition, PrintAvailableCommands(Response &r, const Partition &partition,
unsigned permission) noexcept unsigned permission) noexcept
{ {
for (unsigned i = 0; i < num_commands; ++i) { for (const auto & i : commands) {
const struct command *cmd = &commands[i]; const struct command *cmd = &i;
if (cmd->permission == (permission & cmd->permission) && if (cmd->permission == (permission & cmd->permission) &&
command_available(partition, cmd)) command_available(partition, cmd))
@ -260,8 +260,8 @@ PrintAvailableCommands(Response &r, const Partition &partition,
static CommandResult static CommandResult
PrintUnavailableCommands(Response &r, unsigned permission) noexcept PrintUnavailableCommands(Response &r, unsigned permission) noexcept
{ {
for (unsigned i = 0; i < num_commands; ++i) { for (const auto & i : commands) {
const struct command *cmd = &commands[i]; const struct command *cmd = &i;
if (cmd->permission != (permission & cmd->permission)) if (cmd->permission != (permission & cmd->permission))
r.Format("command: %s\n", cmd->cmd); r.Format("command: %s\n", cmd->cmd);

View File

@ -516,8 +516,8 @@ parse_xing(struct xing *xing, struct mad_bitptr *ptr, int *oldbitlen) noexcept
if (xing->flags & XING_TOC) { if (xing->flags & XING_TOC) {
if (bitlen < 800) if (bitlen < 800)
return false; return false;
for (unsigned i = 0; i < 100; ++i) for (unsigned char & i : xing->toc)
xing->toc[i] = mad_bit_read(ptr, 8); i = mad_bit_read(ptr, 8);
bitlen -= 800; bitlen -= 800;
} }

View File

@ -84,8 +84,8 @@ NeighborGlue::Open()
void void
NeighborGlue::Close() noexcept NeighborGlue::Close() noexcept
{ {
for (auto i = explorers.begin(), end = explorers.end(); i != end; ++i) for (auto & explorer : explorers)
i->explorer->Close(); explorer.explorer->Close();
} }
NeighborGlue::List NeighborGlue::List