mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02: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:
parent
c63364610f
commit
680bc2cbb3
13 changed files with 74 additions and 74 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue