Skip to content

Commit

Permalink
scripted-diff: Fully remove BOOST_FOREACH
Browse files Browse the repository at this point in the history
-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
jtimon authored and str4d committed Nov 23, 2020
1 parent 32433c2 commit 92a867f
Show file tree
Hide file tree
Showing 49 changed files with 307 additions and 307 deletions.
6 changes: 3 additions & 3 deletions src/alert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ void CUnsignedAlert::SetNull()
std::string CUnsignedAlert::ToString() const
{
std::string strSetCancel;
BOOST_FOREACH(int n, setCancel)
for (int n : setCancel)
strSetCancel += strprintf("%d ", n);
std::string strSetSubVer;
BOOST_FOREACH(const std::string& str, setSubVer)
for (const std::string& str : setSubVer)
strSetSubVer += "\"" + str + "\" ";
return strprintf(
"CAlert(\n"
Expand Down Expand Up @@ -240,7 +240,7 @@ bool CAlert::ProcessAlert(const std::vector<unsigned char>& alertKey, bool fThre
}

// 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))
Expand Down
2 changes: 1 addition & 1 deletion src/bitcoin-tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& strInput)
ProduceSignature(MutableTransactionSignatureCreator(&keystore, &mergedTx, i, amount, nHashType), prevPubKey, sigdata, consensusBranchId);

// ... and merge in other signatures:
BOOST_FOREACH(const CTransaction& txv, txVariants)
for (const CTransaction& txv : txVariants)
sigdata = CombineSignatures(prevPubKey, MutableTransactionSignatureChecker(&mergedTx, i, amount), sigdata, DataFromTransaction(txv, i), consensusBranchId);
UpdateTransaction(mergedTx, i, sigdata);

Expand Down
2 changes: 1 addition & 1 deletion src/bloom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,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))
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
8 changes: 4 additions & 4 deletions src/coins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,9 +920,9 @@ std::optional<UnsatisfiedShieldedReq> CCoinsViewCache::HaveShieldedRequirements(
{
boost::unordered_map<uint256, SproutMerkleTree, CCoinsKeyHasher> intermediates;

BOOST_FOREACH(const JSDescription &joinsplit, tx.vJoinSplit)
for (const JSDescription &joinsplit : tx.vJoinSplit)
{
BOOST_FOREACH(const uint256& nullifier, joinsplit.nullifiers)
for (const uint256& nullifier : joinsplit.nullifiers)
{
if (GetNullifier(nullifier, SPROUT)) {
// If the nullifier is set, this transaction
Expand All @@ -949,7 +949,7 @@ std::optional<UnsatisfiedShieldedReq> CCoinsViewCache::HaveShieldedRequirements(
return UnsatisfiedShieldedReq::SproutUnknownAnchor;
}

BOOST_FOREACH(const uint256& commitment, joinsplit.commitments)
for (const uint256& commitment : joinsplit.commitments)
{
tree.append(commitment);
}
Expand Down Expand Up @@ -1011,7 +1011,7 @@ double CCoinsViewCache::GetPriority(const CTransaction &tx, int nHeight) const

// FIXME: this logic is partially duplicated between here and CreateNewBlock in miner.cpp.
double dResult = 0.0;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
for (const CTxIn& txin : tx.vin)
{
const CCoins* coins = AccessCoins(txin.prevout.hash);
assert(coins);
Expand Down
6 changes: 3 additions & 3 deletions src/coins.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class CCoins
}

void ClearUnspendable() {
BOOST_FOREACH(CTxOut &txout, vout) {
for (CTxOut &txout : vout) {
if (txout.scriptPubKey.IsUnspendable())
txout.SetNull();
}
Expand Down Expand Up @@ -228,15 +228,15 @@ class CCoins
//! check whether the entire CCoins is spent
//! 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;
}

size_t DynamicMemoryUsage() const {
size_t ret = memusage::DynamicUsage(vout);
BOOST_FOREACH(const CTxOut &out, vout) {
for (const CTxOut &out : vout) {
ret += RecursiveDynamicUsage(out.scriptPubKey);
}
return ret;
Expand Down
2 changes: 1 addition & 1 deletion src/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry)
entry.pushKV("locktime", (int64_t)tx.nLockTime);

UniValue vin(UniValue::VARR);
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
for (const CTxIn& txin : tx.vin) {
UniValue in(UniValue::VOBJ);
if (tx.IsCoinBase())
in.pushKV("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()));
Expand Down
2 changes: 1 addition & 1 deletion src/gtest/test_joinsplit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ for test_input in TEST_VECTORS:
}
};

BOOST_FOREACH(std::vector<std::string>& v, tests) {
for (std::vector<std::string>& v : tests) {
Ed25519VerificationKey joinSplitPubKey;
auto pubKeyBytes = uint256S(v[3]);
std::copy(pubKeyBytes.begin(), pubKeyBytes.end(), joinSplitPubKey.bytes);
Expand Down
4 changes: 2 additions & 2 deletions src/gtest/test_merkletree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void test_tree(
expect_ser_test_vector(ser_tests[i], tree, tree);

bool first = true; // The first witness can never form a path
BOOST_FOREACH(Witness& wit, witnesses)
for (Witness& wit : witnesses)
{
// Append the same commitment to all the witnesses
wit.append(test_commitment);
Expand All @@ -121,7 +121,7 @@ void test_tree(
// Tree should be full now
ASSERT_THROW(tree.append(uint256()), std::runtime_error);

BOOST_FOREACH(Witness& wit, witnesses)
for (Witness& wit : witnesses)
{
ASSERT_THROW(wit.append(uint256()), std::runtime_error);
}
Expand Down
2 changes: 1 addition & 1 deletion src/httprpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static bool multiUserAuthorized(std::string strUserPass)

if (mapMultiArgs.count("-rpcauth") > 0) {
//Search for multi-user login/pass "rpcauth" from config
BOOST_FOREACH(std::string strRPCAuth, mapMultiArgs["-rpcauth"])
for (std::string strRPCAuth : mapMultiArgs["-rpcauth"])
{
std::vector<std::string> vFields;
boost::split(vFields, strRPCAuth, boost::is_any_of(":$"));
Expand Down
20 changes: 10 additions & 10 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ void CleanupBlockRevFiles()
// keeping a separate counter. Once we hit a gap (or if 0 doesn't exist)
// start removing block files.
int nContigCounter = 0;
BOOST_FOREACH(const PAIRTYPE(string, path)& item, mapBlockFiles) {
for (const PAIRTYPE(string, path)& item : mapBlockFiles) {
if (atoi(item.first) == nContigCounter) {
nContigCounter++;
continue;
Expand Down Expand Up @@ -640,7 +640,7 @@ void ThreadImport(std::vector<fs::path> vImportFiles)
}

// -loadblock=
BOOST_FOREACH(const fs::path& path, vImportFiles) {
for (const fs::path& path : vImportFiles) {
FILE *file = fsbridge::fopen(path, "rb");
if (file) {
CImportingNow imp;
Expand Down Expand Up @@ -1240,7 +1240,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)

// sanitize comments per BIP-0014, format user agent and check total size
std::vector<string> uacomments;
BOOST_FOREACH(string cmt, mapMultiArgs["-uacomment"])
for (string cmt : mapMultiArgs["-uacomment"])
{
if (cmt != SanitizeString(cmt, SAFE_CHARS_UA_COMMENT))
return InitError(strprintf("User Agent comment (%s) contains unsafe characters.", cmt));
Expand All @@ -1254,7 +1254,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)

if (mapArgs.count("-onlynet")) {
std::set<enum Network> nets;
BOOST_FOREACH(const std::string& snet, mapMultiArgs["-onlynet"]) {
for (const 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 @@ -1268,7 +1268,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
}

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 @@ -1317,13 +1317,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
bool fBound = false;
if (fListen) {
if (mapArgs.count("-bind") || mapArgs.count("-whitebind")) {
BOOST_FOREACH(const std::string& strBind, mapMultiArgs["-bind"]) {
for (const 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(const std::string& strBind, mapMultiArgs["-whitebind"]) {
for (const 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 @@ -1343,15 +1343,15 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
}

if (mapArgs.count("-externalip")) {
BOOST_FOREACH(const std::string& strAddr, mapMultiArgs["-externalip"]) {
for (const std::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(const std::string& strDest, mapMultiArgs["-seednode"])
for (const std::string& strDest : mapMultiArgs["-seednode"])
AddOneShot(strDest);

#if ENABLE_ZMQ
Expand Down Expand Up @@ -1655,7 +1655,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
std::vector<fs::path> vImportFiles;
if (mapArgs.count("-loadblock"))
{
BOOST_FOREACH(const std::string& strFile, mapMultiArgs["-loadblock"])
for (const std::string& strFile : mapMultiArgs["-loadblock"])
vImportFiles.push_back(strFile);
}
threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles));
Expand Down
Loading

0 comments on commit 92a867f

Please sign in to comment.