diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2017-06-04 22:02:43 +0200 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2017-10-09 21:31:58 +0200 |
commit | 680bc2cbb34d6bedd0e64b17d0555216572be4c8 (patch) | |
tree | 49556f05754010cf334e67ed322e3a1dc6c29a64 /src/rpc | |
parent | c63364610f4a041df1c1bd81d01b1f6856160749 (diff) |
Use range-based for loops (C++11) when looping over map elements
Before this commit:
for (std::map<T1, T2>::iterator x = y.begin(); x != y.end(); ++x) {
}
After this commit:
for (auto& x : y) {
}
Diffstat (limited to 'src/rpc')
-rw-r--r-- | src/rpc/net.cpp | 6 | ||||
-rw-r--r-- | src/rpc/server.cpp | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index a3d3df26a3..86beba30d5 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -569,11 +569,11 @@ UniValue listbanned(const JSONRPCRequest& request) g_connman->GetBanned(banMap); UniValue bannedAddresses(UniValue::VARR); - for (banmap_t::iterator it = banMap.begin(); it != banMap.end(); it++) + for (const auto& entry : banMap) { - CBanEntry banEntry = (*it).second; + const CBanEntry& banEntry = entry.second; UniValue rec(UniValue::VOBJ); - rec.push_back(Pair("address", (*it).first.ToString())); + rec.push_back(Pair("address", entry.first.ToString())); rec.push_back(Pair("banned_until", banEntry.nBanUntil)); rec.push_back(Pair("ban_created", banEntry.nCreateTime)); rec.push_back(Pair("ban_reason", banEntry.banReasonToString())); diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index a73b697e01..53e90b93fd 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -160,8 +160,8 @@ std::string CRPCTable::help(const std::string& strCommand, const JSONRPCRequest& std::set<rpcfn_type> setDone; std::vector<std::pair<std::string, const CRPCCommand*> > vCommands; - for (std::map<std::string, const CRPCCommand*>::const_iterator mi = mapCommands.begin(); mi != mapCommands.end(); ++mi) - vCommands.push_back(make_pair(mi->second->category + mi->first, mi->second)); + for (const auto& entry : mapCommands) + vCommands.push_back(make_pair(entry.second->category + entry.first, entry.second)); sort(vCommands.begin(), vCommands.end()); JSONRPCRequest jreq(helpreq); |