Use range-based for loops (C++11) when looping over vector elements

This commit is contained in:
practicalswift
2017-05-18 09:42:14 +02:00
parent ea6fde3f1d
commit 211adc074a
5 changed files with 22 additions and 25 deletions

View File

@@ -754,8 +754,8 @@ void PeerLogicValidation::BlockConnected(const std::shared_ptr<const CBlock>& pb
const CTransaction& tx = *ptx;
// Which orphan pool entries must we evict?
for (size_t j = 0; j < tx.vin.size(); j++) {
auto itByPrev = mapOrphanTransactionsByPrev.find(tx.vin[j].prevout);
for (const auto& txin : tx.vin) {
auto itByPrev = mapOrphanTransactionsByPrev.find(txin.prevout);
if (itByPrev == mapOrphanTransactionsByPrev.end()) continue;
for (auto mi = itByPrev->second.begin(); mi != itByPrev->second.end(); ++mi) {
const CTransaction& orphanTx = *(*mi)->second.tx;
@@ -1553,10 +1553,8 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
uint32_t nFetchFlags = GetFetchFlags(pfrom);
for (unsigned int nInv = 0; nInv < vInv.size(); nInv++)
for (CInv &inv : vInv)
{
CInv &inv = vInv[nInv];
if (interruptMsgProc)
return true;