aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorpracticalswift <practicalswift@users.noreply.github.com>2017-06-04 22:02:43 +0200
committerpracticalswift <practicalswift@users.noreply.github.com>2017-10-09 21:31:58 +0200
commit680bc2cbb34d6bedd0e64b17d0555216572be4c8 (patch)
tree49556f05754010cf334e67ed322e3a1dc6c29a64 /src/net.cpp
parentc63364610f4a041df1c1bd81d01b1f6856160749 (diff)
downloadbitcoin-680bc2cbb34d6bedd0e64b17d0555216572be4c8.tar.xz
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/net.cpp')
-rw-r--r--src/net.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/net.cpp b/src/net.cpp
index ea3840a708..0768fd958c 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -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;
}