mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
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) {
}
This commit is contained in:
@@ -110,13 +110,13 @@ bool GetLocal(CService& addr, const CNetAddr *paddrPeer)
|
||||
int nBestReachability = -1;
|
||||
{
|
||||
LOCK(cs_mapLocalHost);
|
||||
for (std::map<CNetAddr, LocalServiceInfo>::iterator it = mapLocalHost.begin(); it != mapLocalHost.end(); it++)
|
||||
for (const auto& entry : mapLocalHost)
|
||||
{
|
||||
int nScore = (*it).second.nScore;
|
||||
int nReachability = (*it).first.GetReachabilityFrom(paddrPeer);
|
||||
int nScore = entry.second.nScore;
|
||||
int nReachability = entry.first.GetReachabilityFrom(paddrPeer);
|
||||
if (nReachability > nBestReachability || (nReachability == nBestReachability && nScore > nBestScore))
|
||||
{
|
||||
addr = CService((*it).first, (*it).second.nPort);
|
||||
addr = CService(entry.first, entry.second.nPort);
|
||||
nBestReachability = nReachability;
|
||||
nBestScore = nScore;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user