diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2984,8 +2984,7 @@ { "hidden", "waitforblockheight", waitforblockheight, {"height","timeout"} }, }; // clang-format on - - for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) { - t.appendCommand(commands[vcidx].name, &commands[vcidx]); + for (const auto &c : commands) { + t.appendCommand(c.name, &c); } } diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -1167,8 +1167,7 @@ {"util", "estimatefee", estimatefee, {"nblocks"}}, }; // clang-format on - - for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) { - t.appendCommand(commands[vcidx].name, &commands[vcidx]); + for (const auto &c : commands) { + t.appendCommand(c.name, &c); } } diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -797,8 +797,7 @@ { "hidden", "echojson", echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}}, }; // clang-format on - - for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) { - t.appendCommand(commands[vcidx].name, &commands[vcidx]); + for (const auto &c : commands) { + t.appendCommand(c.name, &c); } } diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -1060,8 +1060,7 @@ { "hidden", "addpeeraddress", addpeeraddress, {"address", "port"} }, }; // clang-format on - - for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) { - t.appendCommand(commands[vcidx].name, &commands[vcidx]); + for (const auto &c : commands) { + t.appendCommand(c.name, &c); } } diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -2159,8 +2159,7 @@ { "blockchain", "verifytxoutproof", verifytxoutproof, {"proof"} }, }; // clang-format on - - for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) { - t.appendCommand(commands[vcidx].name, &commands[vcidx]); + for (const auto &c : commands) { + t.appendCommand(c.name, &c); } } diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -310,13 +310,8 @@ // clang-format on CRPCTable::CRPCTable() { - unsigned int vcidx; - for (vcidx = 0; vcidx < (sizeof(vRPCCommands) / sizeof(vRPCCommands[0])); - vcidx++) { - const CRPCCommand *pcmd; - - pcmd = &vRPCCommands[vcidx]; - mapCommands[pcmd->name].push_back(pcmd); + for (const auto &c : vRPCCommands) { + appendCommand(c.name, &c); } }