diff options
author | MarcoFalke <falke.marco@gmail.com> | 2018-06-15 12:32:30 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2018-06-15 12:32:39 -0400 |
commit | be27048a1842b76de5b230383c1466b72dfd8cc5 (patch) | |
tree | 0a06c781076b00d278c018d35ab0f04c0e52a1f4 /src/validation.cpp | |
parent | 280924e6729b83b979a1b7384927b4fbc941b2fd (diff) | |
parent | 9b72c988a0050d8932275c74c60928918ee7ef71 (diff) |
Merge #13241: scripted-diff: Avoid temporary copies when looping over std::map
9b72c988a0 scripted-diff: Avoid temporary copies when looping over std::map (Ben Woosley)
Pull request description:
The ::value_type of the std::map/std::multimap/std::unordered_map containers is
std::pair<const Key, T>. Dropping the const results in an unnecessary copy,
for example in C++11 range-based loops.
For this I started with a more general scripted diff, then narrowed it down
based on the inspection showing that all actual map/multimap/unordered_map
variables used in loops start with m or have map in the name.
Tree-SHA512: b656d66b69ffa1eb954124aa8ae2bc5436ca50262abefa93bdda55cfcdaffc5ff90cd40539051a2bd06355ba69ddf245265cc8764eebff66d761b3aec06155a9
Diffstat (limited to 'src/validation.cpp')
-rw-r--r-- | src/validation.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index d94b7c7d06..5d2b65c95c 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3837,7 +3837,7 @@ bool CChainState::LoadBlockIndex(const Consensus::Params& consensus_params, CBlo // Calculate nChainWork std::vector<std::pair<int, CBlockIndex*> > vSortedByHeight; vSortedByHeight.reserve(mapBlockIndex.size()); - for (const std::pair<uint256, CBlockIndex*>& item : mapBlockIndex) + for (const std::pair<const uint256, CBlockIndex*>& item : mapBlockIndex) { CBlockIndex* pindex = item.second; vSortedByHeight.push_back(std::make_pair(pindex->nHeight, pindex)); @@ -3904,7 +3904,7 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams) // Check presence of blk files LogPrintf("Checking all blk files are present...\n"); std::set<int> setBlkDataFiles; - for (const std::pair<uint256, CBlockIndex*>& item : mapBlockIndex) + for (const std::pair<const uint256, CBlockIndex*>& item : mapBlockIndex) { CBlockIndex* pindex = item.second; if (pindex->nStatus & BLOCK_HAVE_DATA) { |