refactor: Use C++11 range based for loops to simplify rpc code

This commit is contained in:
MarcoFalke 2020-07-15 21:29:41 +02:00
parent fa459bdc87
commit fa89ca9b5b
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548
6 changed files with 17 additions and 22 deletions

View File

@ -2407,7 +2407,7 @@ static const CRPCCommand commands[] =
{ "hidden", "dumptxoutset", &dumptxoutset, {"path"} },
};
// 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);
}
}

View File

@ -1200,7 +1200,7 @@ static const CRPCCommand commands[] =
{ "hidden", "estimaterawfee", &estimaterawfee, {"conf_target", "threshold"} },
};
// 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);
}
}

View File

@ -619,7 +619,7 @@ static const CRPCCommand commands[] =
{ "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);
}
}

View File

@ -796,7 +796,7 @@ static const CRPCCommand commands[] =
{ "network", "getnodeaddresses", &getnodeaddresses, {"count"} },
};
// 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);
}
}

View File

@ -1821,7 +1821,7 @@ static const CRPCCommand commands[] =
{ "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);
}
}

View File

@ -256,13 +256,8 @@ static const CRPCCommand vRPCCommands[] =
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);
}
}