Skip to content

Commit

Permalink
Merge dashpay#830: [Refactor] Remove BOOST_FOREACH
Browse files Browse the repository at this point in the history
4f6cd20 Cleanup clang's range loop analysis warnings (Fuzzbawls)
e1c549e [Refactor] Remove useless BOOST includes and readd where needed (warrows)
4d44c97 [Refactoring] Replace BOOST FOREACH with for : (warrows)

Tree-SHA512: a61e8968a28c86f33f753b693559a58a632e01b6408b7f0653772206fa9f20fb2df83e432ed74e33d1bed29a302ff4b98c30bbe53111faf1f50ed3acf8888190
  • Loading branch information
Fuzzbawls committed May 15, 2019
2 parents 0c071c3 + 4f6cd20 commit 81038da
Show file tree
Hide file tree
Showing 69 changed files with 437 additions and 461 deletions.
12 changes: 6 additions & 6 deletions src/activemasternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ bool CActiveMasternode::SendMasternodePing(std::string& errorMessage)

LogPrint("masternode", "dseep - relaying from active mn, %s \n", vin.ToString().c_str());
LOCK(cs_vNodes);
BOOST_FOREACH (CNode* pnode, vNodes)
for (CNode* pnode : vNodes)
pnode->PushMessage("dseep", vin, vchMasterNodeSignature, masterNodeSignatureTime, false);

/*
Expand Down Expand Up @@ -326,7 +326,7 @@ bool CActiveMasternode::CreateBroadcast(CTxIn vin, CService service, CKey keyCol
}

LOCK(cs_vNodes);
BOOST_FOREACH (CNode* pnode, vNodes)
for (CNode* pnode : vNodes)
pnode->PushMessage("dsee", vin, service, vchMasterNodeSignature, masterNodeSignatureTime, pubKeyCollateralAddress, pubKeyMasternode, -1, -1, masterNodeSignatureTime, PROTOCOL_VERSION, donationAddress, donationPercantage);

/*
Expand Down Expand Up @@ -366,7 +366,7 @@ bool CActiveMasternode::GetMasterNodeVin(CTxIn& vin, CPubKey& pubkey, CKey& secr
}

bool found = false;
BOOST_FOREACH (COutput& out, possibleCoins) {
for (COutput& out : possibleCoins) {
if (out.tx->GetHash() == txHash && out.i == outputIndex) {
selectedOutput = &out;
found = true;
Expand Down Expand Up @@ -432,7 +432,7 @@ vector<COutput> CActiveMasternode::SelectCoinsMasternode()
// Temporary unlock MN coins from masternode.conf
if (GetBoolArg("-mnconflock", true)) {
uint256 mnTxHash;
BOOST_FOREACH (CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) {
for (CMasternodeConfig::CMasternodeEntry mne : masternodeConfig.getEntries()) {
mnTxHash.SetHex(mne.getTxHash());

int nIndex;
Expand All @@ -450,12 +450,12 @@ vector<COutput> CActiveMasternode::SelectCoinsMasternode()

// Lock MN coins from masternode.conf back if they where temporary unlocked
if (!confLockedCoins.empty()) {
BOOST_FOREACH (COutPoint outpoint, confLockedCoins)
for (COutPoint outpoint : confLockedCoins)
pwalletMain->LockCoin(outpoint);
}

// Filter
BOOST_FOREACH (const COutput& out, vCoins) {
for (const COutput& out : vCoins) {
if (out.tx->vout[out.i].nValue == 10000 * COIN) { //exactly
filteredCoins.push_back(out);
}
Expand Down
5 changes: 2 additions & 3 deletions src/alert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/foreach.hpp>
#include <boost/thread.hpp>

using namespace std;
Expand Down Expand Up @@ -52,7 +51,7 @@ std::string CUnsignedAlert::ToString() const
for (auto& n: setCancel)
strSetCancel += strprintf("%d ", n);
std::string strSetSubVer;
BOOST_FOREACH (std::string str, setSubVer)
for (std::string str : setSubVer)
strSetSubVer += "\"" + str + "\" ";
return strprintf(
"CAlert(\n"
Expand Down Expand Up @@ -213,7 +212,7 @@ bool CAlert::ProcessAlert(bool fThread)
}

// Check if this alert has been cancelled
BOOST_FOREACH (PAIRTYPE(const uint256, CAlert) & item, mapAlerts) {
for (PAIRTYPE(const uint256, CAlert) & item : mapAlerts) {
const CAlert& alert = item.second;
if (alert.Cancels(*this)) {
LogPrint("alert", "alert already cancelled by %d\n", alert.nID);
Expand Down
3 changes: 1 addition & 2 deletions src/bloom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <math.h>
#include <stdlib.h>

#include <boost/foreach.hpp>

#define LN2SQUARED 0.4804530139182014246671025263266649717305529515945455
#define LN2 0.6931471805599453094172321214581765680755001343602552
Expand Down Expand Up @@ -207,7 +206,7 @@ bool CBloomFilter::IsRelevantAndUpdate(const CTransaction& tx)
if (fFound)
return true;

BOOST_FOREACH (const CTxIn& txin, tx.vin) {
for (const CTxIn& txin : tx.vin) {
// Match if the filter contains an outpoint tx spends
if (contains(txin.prevout))
return true;
Expand Down
1 change: 0 additions & 1 deletion src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <vector>

#include <boost/foreach.hpp>

struct CDiskBlockPos {
int nFile;
Expand Down
5 changes: 2 additions & 3 deletions src/checkqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <algorithm>
#include <vector>

#include <boost/foreach.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/locks.hpp>
#include <boost/thread/mutex.hpp>
Expand Down Expand Up @@ -119,7 +118,7 @@ class CCheckQueue
fOk = fAllOk;
}
// execute work
BOOST_FOREACH (T& check, vChecks)
for (T& check : vChecks)
if (fOk)
fOk = check();
vChecks.clear();
Expand All @@ -146,7 +145,7 @@ class CCheckQueue
void Add(std::vector<T>& vChecks)
{
boost::unique_lock<boost::mutex> lock(mutex);
BOOST_FOREACH (T& check, vChecks) {
for (T& check : vChecks) {
queue.push_back(T());
check.swap(queue.back());
}
Expand Down
5 changes: 2 additions & 3 deletions src/coins.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <assert.h>
#include <stdint.h>

#include <boost/foreach.hpp>
#include <boost/unordered_map.hpp>

/**
Expand Down Expand Up @@ -128,7 +127,7 @@ class CCoins

void ClearUnspendable()
{
BOOST_FOREACH (CTxOut& txout, vout) {
for (CTxOut& txout : vout) {
if (txout.scriptPubKey.IsUnspendable())
txout.SetNull();
}
Expand Down Expand Up @@ -279,7 +278,7 @@ class CCoins
//! note that only !IsPruned() CCoins can be serialized
bool IsPruned() const
{
BOOST_FOREACH (const CTxOut& out, vout)
for (const CTxOut& out : vout)
if (!out.IsNull())
return false;
return true;
Expand Down
3 changes: 1 addition & 2 deletions src/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "utilmoneystr.h"
#include "utilstrencodings.h"

#include <boost/foreach.hpp>

using namespace std;

Expand Down Expand Up @@ -83,7 +82,7 @@ void ScriptPubKeyToUniv(const CScript& scriptPubKey,
out.pushKV("type", GetTxnOutputType(type));

UniValue a(UniValue::VARR);
BOOST_FOREACH (const CTxDestination& addr, addresses)
for (const CTxDestination& addr : addresses)
a.push_back(CBitcoinAddress(addr).ToString());
out.pushKV("addresses", a);
}
Expand Down
3 changes: 1 addition & 2 deletions src/crypter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "init.h"
#include "uint256.h"

#include <boost/foreach.hpp>
#include <openssl/aes.h>
#include <openssl/evp.h>
#include "wallet/wallet.h"
Expand Down Expand Up @@ -358,7 +357,7 @@ bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
return false;

fUseCrypto = true;
BOOST_FOREACH (KeyMap::value_type& mKey, mapKeys) {
for (KeyMap::value_type& mKey : mapKeys) {
const CKey& key = mKey.second;
CPubKey vchPubKey = key.GetPubKey();
CKeyingMaterial vchSecret(key.begin(), key.end());
Expand Down
21 changes: 11 additions & 10 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#include <boost/filesystem.hpp>
#include <boost/interprocess/sync/file_lock.hpp>
#include <boost/thread.hpp>
#include <boost/foreach.hpp>
#include <openssl/crypto.h>

#if ENABLE_ZMQ
Expand Down Expand Up @@ -695,7 +696,7 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
}

// -loadblock=
BOOST_FOREACH (boost::filesystem::path& path, vImportFiles) {
for (boost::filesystem::path& path : vImportFiles) {
FILE* file = fopen(path.string().c_str(), "rb");
if (file) {
CImportingNow imp;
Expand Down Expand Up @@ -1264,7 +1265,7 @@ bool AppInit2()

if (mapArgs.count("-onlynet")) {
std::set<enum Network> nets;
BOOST_FOREACH (std::string snet, mapMultiArgs["-onlynet"]) {
for (std::string snet : mapMultiArgs["-onlynet"]) {
enum Network net = ParseNetwork(snet);
if (net == NET_UNROUTABLE)
return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet));
Expand All @@ -1278,7 +1279,7 @@ bool AppInit2()
}

if (mapArgs.count("-whitelist")) {
BOOST_FOREACH (const std::string& net, mapMultiArgs["-whitelist"]) {
for (const std::string& net : mapMultiArgs["-whitelist"]) {
CSubNet subnet(net);
if (!subnet.IsValid())
return InitError(strprintf(_("Invalid netmask specified in -whitelist: '%s'"), net));
Expand Down Expand Up @@ -1338,13 +1339,13 @@ bool AppInit2()
bool fBound = false;
if (fListen) {
if (mapArgs.count("-bind") || mapArgs.count("-whitebind")) {
BOOST_FOREACH (std::string strBind, mapMultiArgs["-bind"]) {
for (std::string strBind : mapMultiArgs["-bind"]) {
CService addrBind;
if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false))
return InitError(strprintf(_("Cannot resolve -bind address: '%s'"), strBind));
fBound |= Bind(addrBind, (BF_EXPLICIT | BF_REPORT_ERROR));
}
BOOST_FOREACH (std::string strBind, mapMultiArgs["-whitebind"]) {
for (std::string strBind : mapMultiArgs["-whitebind"]) {
CService addrBind;
if (!Lookup(strBind.c_str(), addrBind, 0, false))
return InitError(strprintf(_("Cannot resolve -whitebind address: '%s'"), strBind));
Expand All @@ -1363,15 +1364,15 @@ bool AppInit2()
}

if (mapArgs.count("-externalip")) {
BOOST_FOREACH (string strAddr, mapMultiArgs["-externalip"]) {
for (string strAddr : mapMultiArgs["-externalip"]) {
CService addrLocal(strAddr, GetListenPort(), fNameLookup);
if (!addrLocal.IsValid())
return InitError(strprintf(_("Cannot resolve -externalip address: '%s'"), strAddr));
AddLocal(CService(strAddr, GetListenPort(), fNameLookup), LOCAL_MANUAL);
}
}

BOOST_FOREACH (string strDest, mapMultiArgs["-seednode"])
for (string strDest : mapMultiArgs["-seednode"])
AddOneShot(strDest);

#if ENABLE_ZMQ
Expand Down Expand Up @@ -1745,7 +1746,7 @@ bool AppInit2()

// Restore wallet transaction metadata after -zapwallettxes=1
if (GetBoolArg("-zapwallettxes", false) && GetArg("-zapwallettxes", "1") != "2") {
BOOST_FOREACH (const CWalletTx& wtxOld, vWtx) {
for (const CWalletTx& wtxOld : vWtx) {
uint256 hash = wtxOld.GetHash();
std::map<uint256, CWalletTx>::iterator mi = pwalletMain->mapWallet.find(hash);
if (mi != pwalletMain->mapWallet.end()) {
Expand Down Expand Up @@ -1796,7 +1797,7 @@ bool AppInit2()

std::vector<boost::filesystem::path> vImportFiles;
if (mapArgs.count("-loadblock")) {
BOOST_FOREACH (string strFile, mapMultiArgs["-loadblock"])
for (string strFile : mapMultiArgs["-loadblock"])
vImportFiles.push_back(strFile);
}
threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles));
Expand Down Expand Up @@ -1902,7 +1903,7 @@ bool AppInit2()
LOCK(pwalletMain->cs_wallet);
LogPrintf("Locking Masternodes:\n");
uint256 mnTxHash;
BOOST_FOREACH (CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) {
for (CMasternodeConfig::CMasternodeEntry mne : masternodeConfig.getEntries()) {
LogPrintf(" %s %s\n", mne.getTxHash(), mne.getOutputIndex());
mnTxHash.SetHex(mne.getTxHash());
COutPoint outpoint = COutPoint(mnTxHash, (unsigned int) std::stoul(mne.getOutputIndex().c_str()));
Expand Down
4 changes: 2 additions & 2 deletions src/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static bool SelectBlockFromCandidates(
bool fSelected = false;
uint256 hashBest = 0;
*pindexSelected = (const CBlockIndex*)0;
BOOST_FOREACH (const PAIRTYPE(int64_t, uint256) & item, vSortedByTimestamp) {
for (const PAIRTYPE(int64_t, uint256) & item : vSortedByTimestamp) {
if (!mapBlockIndex.count(item.second))
return error("SelectBlockFromCandidates: failed to find block index for candidate block %s", item.second.ToString().c_str());

Expand Down Expand Up @@ -225,7 +225,7 @@ bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64_t& nStakeMod
strSelectionMap.replace(pindex->nHeight - nHeightFirstCandidate, 1, "=");
pindex = pindex->pprev;
}
BOOST_FOREACH (const PAIRTYPE(uint256, const CBlockIndex*) & item, mapSelectedBlocks) {
for (const std::pair<const uint256, const CBlockIndex*> &item : mapSelectedBlocks) {
// 'S' indicates selected proof-of-stake blocks
// 'W' indicates selected proof-of-work blocks
strSelectionMap.replace(item.second->nHeight - nHeightFirstCandidate, 1, item.second->IsProofOfStake() ? "S" : "W");
Expand Down
1 change: 0 additions & 1 deletion src/keystore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "script/standard.h"
#include "util.h"

#include <boost/foreach.hpp>

bool CKeyStore::GetPubKey(const CKeyID& address, CPubKey& vchPubKeyOut) const
{
Expand Down
Loading

0 comments on commit 81038da

Please sign in to comment.