Skip to content

Commit

Permalink
[Refactoring] Replace BOOST FOREACH with for :
Browse files Browse the repository at this point in the history
Done using following script:

-BEGIN VERIFY SCRIPT-
sed -i 's/BOOST_FOREACH *(\(.*\),/for (\1 :/' ./src/*.h ./src/*.cpp
./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ;
-END VERIFY SCRIPT-
  • Loading branch information
Warrows authored and random-zebra committed May 15, 2019
1 parent 0c071c3 commit 4d44c97
Show file tree
Hide file tree
Showing 62 changed files with 433 additions and 432 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
4 changes: 2 additions & 2 deletions src/alert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,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 +213,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
2 changes: 1 addition & 1 deletion src/bloom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,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
4 changes: 2 additions & 2 deletions src/checkqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,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 +146,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
4 changes: 2 additions & 2 deletions src/coins.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,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 +279,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
2 changes: 1 addition & 1 deletion src/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,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
2 changes: 1 addition & 1 deletion src/crypter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,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
20 changes: 10 additions & 10 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,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 +1264,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 +1278,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 +1338,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 +1363,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 +1745,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 +1796,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 +1902,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 PAIRTYPE(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
Loading

0 comments on commit 4d44c97

Please sign in to comment.