From d6d462fd7b75d5dc47ece7d0c1e7bb65b054d30e Mon Sep 17 00:00:00 2001 From: Pasta Date: Fri, 12 Jul 2019 23:58:15 -0500 Subject: [PATCH] #10193 scripted-diff: Remove BOOST_REVERSE_FOREACH -BEGIN VERIFY SCRIPT- sed -i 's/BOOST_REVERSE_FOREACH(\(.*\), \(.*\))/for (\1 : reverse_iterate(\2))/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ; -END VERIFY SCRIPT- Signed-off-by: Pasta --- src/checkpoints.cpp | 2 +- src/net_processing.cpp | 4 ++-- src/test/prevector_tests.cpp | 4 ++-- src/txmempool.cpp | 2 +- src/validation.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 37490b2515..fd6666c517 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -19,7 +19,7 @@ namespace Checkpoints { { const MapCheckpoints& checkpoints = data.mapCheckpoints; - BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, checkpoints) + for (const MapCheckpoints::value_type& i : reverse_iterate(checkpoints)) { const uint256& hash = i.second; BlockMap::const_iterator t = mapBlockIndex.find(hash); diff --git a/src/net_processing.cpp b/src/net_processing.cpp index addf4d2807..abe7a0aeea 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -900,7 +900,7 @@ void PeerLogicValidation::UpdatedBlockTip(const CBlockIndex *pindexNew, const CB // Relay inventory, but don't relay old inventory during initial block download. connman->ForEachNode([nNewHeight, &vHashes](CNode* pnode) { if (nNewHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : 0)) { - BOOST_REVERSE_FOREACH(const uint256& hash, vHashes) { + for (const uint256& hash : reverse_iterate(vHashes)) { pnode->PushBlockHash(hash); } } @@ -2672,7 +2672,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr } else { std::vector vGetData; // Download as much as possible, from earliest to latest. - BOOST_REVERSE_FOREACH(const CBlockIndex *pindex, vToFetch) { + for (const CBlockIndex *pindex : reverse_iterate(vToFetch)) { if (nodestate->nBlocksInFlight >= MAX_BLOCKS_IN_TRANSIT_PER_PEER) { // Can't download any more from this peer break; diff --git a/src/test/prevector_tests.cpp b/src/test/prevector_tests.cpp index 01308cbbb3..b0e9df8bb6 100644 --- a/src/test/prevector_tests.cpp +++ b/src/test/prevector_tests.cpp @@ -56,13 +56,13 @@ class prevector_tester { for (const T& v : pre_vector) { local_check(v == real_vector[pos++]); } - BOOST_REVERSE_FOREACH(const T& v, pre_vector) { + for (const T& v : reverse_iterate(pre_vector)) { local_check(v == real_vector[--pos]); } for (const T& v : const_pre_vector) { local_check(v == real_vector[pos++]); } - BOOST_REVERSE_FOREACH(const T& v, const_pre_vector) { + for (const T& v : reverse_iterate(const_pre_vector)) { local_check(v == real_vector[--pos]); } CDataStream ss1(SER_DISK, 0); diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 87470ae40c..d80d36de21 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -129,7 +129,7 @@ void CTxMemPool::UpdateTransactionsFromBlock(const std::vector &vHashes // This maximizes the benefit of the descendant cache and guarantees that // setMemPoolChildren will be updated, an assumption made in // UpdateForDescendants. - BOOST_REVERSE_FOREACH(const uint256 &hash, vHashesToUpdate) { + for (const uint256 &hash : reverse_iterate(vHashesToUpdate)) { // we cache the in-mempool children to avoid duplicate updates setEntries setChildren; // calculate children from mapNextTx diff --git a/src/validation.cpp b/src/validation.cpp index 0623a5c9e1..50d677075d 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2594,7 +2594,7 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c nHeight = nTargetHeight; // Connect new blocks. - BOOST_REVERSE_FOREACH(CBlockIndex *pindexConnect, vpindexToConnect) { + for (CBlockIndex *pindexConnect : reverse_iterate(vpindexToConnect)) { if (!ConnectTip(state, chainparams, pindexConnect, pindexConnect == pindexMostWork ? pblock : std::shared_ptr(), connectTrace, disconnectpool)) { if (state.IsInvalid()) { // The block violates a consensus rule.