mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-28 01:59:35 +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:
@@ -3249,8 +3249,8 @@ void PruneOneBlockFile(const int fileNumber)
|
||||
{
|
||||
LOCK(cs_LastBlockFile);
|
||||
|
||||
for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); ++it) {
|
||||
CBlockIndex* pindex = it->second;
|
||||
for (const auto& entry : mapBlockIndex) {
|
||||
CBlockIndex* pindex = entry.second;
|
||||
if (pindex->nFile == fileNumber) {
|
||||
pindex->nStatus &= ~BLOCK_HAVE_DATA;
|
||||
pindex->nStatus &= ~BLOCK_HAVE_UNDO;
|
||||
@@ -3802,8 +3802,8 @@ bool RewindBlockIndex(const CChainParams& params)
|
||||
// Reduce validity flag and have-data flags.
|
||||
// We do this after actual disconnecting, otherwise we'll end up writing the lack of data
|
||||
// to disk before writing the chainstate, resulting in a failure to continue if interrupted.
|
||||
for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); it++) {
|
||||
CBlockIndex* pindexIter = it->second;
|
||||
for (const auto& entry : mapBlockIndex) {
|
||||
CBlockIndex* pindexIter = entry.second;
|
||||
|
||||
// Note: If we encounter an insufficiently validated block that
|
||||
// is on chainActive, it must be because we are a pruning node, and
|
||||
@@ -4078,8 +4078,8 @@ void static CheckBlockIndex(const Consensus::Params& consensusParams)
|
||||
|
||||
// Build forward-pointing map of the entire block tree.
|
||||
std::multimap<CBlockIndex*,CBlockIndex*> forward;
|
||||
for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); it++) {
|
||||
forward.insert(std::make_pair(it->second->pprev, it->second));
|
||||
for (auto& entry : mapBlockIndex) {
|
||||
forward.insert(std::make_pair(entry.second->pprev, entry.second));
|
||||
}
|
||||
|
||||
assert(forward.size() == mapBlockIndex.size());
|
||||
|
||||
Reference in New Issue
Block a user