diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -990,8 +990,8 @@ 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; } @@ -2191,7 +2191,7 @@ LOCK(cs_main); - for (CInv &inv : vInv) { + for (auto &inv : vInv) { if (interruptMsgProc) { return true; } diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -1342,24 +1342,24 @@ uint256 GetPrevoutHash(const CTransaction &txTo) { CHashWriter ss(SER_GETHASH, 0); - for (size_t n = 0; n < txTo.vin.size(); n++) { - ss << txTo.vin[n].prevout; + for (const auto &txin : txTo.vin) { + ss << txin.prevout; } return ss.GetHash(); } uint256 GetSequenceHash(const CTransaction &txTo) { CHashWriter ss(SER_GETHASH, 0); - for (size_t n = 0; n < txTo.vin.size(); n++) { - ss << txTo.vin[n].nSequence; + for (const auto &txin : txTo.vin) { + ss << txin.nSequence; } return ss.GetHash(); } uint256 GetOutputsHash(const CTransaction &txTo) { CHashWriter ss(SER_GETHASH, 0); - for (size_t n = 0; n < txTo.vout.size(); n++) { - ss << txTo.vout[n]; + for (const auto &txout : txTo.vout) { + ss << txout; } return ss.GetHash(); } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2157,12 +2157,12 @@ bool CWalletTx::IsEquivalentTo(const CWalletTx &_tx) const { CMutableTransaction tx1{*this->tx}; CMutableTransaction tx2{*_tx.tx}; - for (CTxIn &in : tx1.vin) { - in.scriptSig = CScript(); + for (auto &txin : tx1.vin) { + txin.scriptSig = CScript(); } - for (CTxIn &in : tx2.vin) { - in.scriptSig = CScript(); + for (auto &txin : tx2.vin) { + txin.scriptSig = CScript(); } return CTransaction(tx1) == CTransaction(tx2); @@ -2787,7 +2787,7 @@ // sign the new tx CTransaction txNewConst(tx); int nIn = 0; - for (auto &input : tx.vin) { + for (const auto &input : tx.vin) { auto mi = mapWallet.find(input.prevout.GetTxId()); if (mi == mapWallet.end() || input.prevout.GetN() >= mi->second.tx->vout.size()) { @@ -3809,7 +3809,7 @@ if (pcoin->tx->vin.size() > 0) { bool any_mine = false; // Group all input addresses with each other. - for (CTxIn txin : pcoin->tx->vin) { + for (const auto txin : pcoin->tx->vin) { CTxDestination address; // If this input isn't mine, ignore it. if (!IsMine(txin)) { @@ -3829,7 +3829,7 @@ // Group change with input addresses. if (any_mine) { - for (CTxOut txout : pcoin->tx->vout) { + for (const auto txout : pcoin->tx->vout) { if (IsChange(txout)) { CTxDestination txoutAddr; if (!ExtractDestination(txout.scriptPubKey, @@ -3849,11 +3849,10 @@ } // Group lone addrs by themselves. - for (unsigned int i = 0; i < pcoin->tx->vout.size(); i++) - if (IsMine(pcoin->tx->vout[i])) { + for (const auto &txout : pcoin->tx->vout) { + if (IsMine(txout)) { CTxDestination address; - if (!ExtractDestination(pcoin->tx->vout[i].scriptPubKey, - address)) { + if (!ExtractDestination(txout.scriptPubKey, address)) { continue; } @@ -3861,6 +3860,7 @@ groupings.insert(grouping); grouping.clear(); } + } } // A set of pointers to groups of addresses.