From 44860dd87a3817cd54141ca712b0c2fc27ab1389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Tim=C3=B3n?= Date: Fri, 2 Jun 2017 03:28:42 +0200 Subject: [PATCH] scripted-diff: Remove PAIRTYPE -BEGIN VERIFY SCRIPT- sed -i 's/PAIRTYPE(\([^,]*\), \([^\)]*\))/std::pair<\1, \2>/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ; sed -i ':a;N;$!ba;s/#define std::pair std::pair\n//' ./src/utilstrencodings.h ; -END VERIFY SCRIPT- Cherry-picked from: 1238f13cf6ccf1177b66df735f360c61ae1dc20b --- src/init.cpp | 2 +- src/net_processing.cpp | 2 +- src/qt/addresstablemodel.cpp | 2 +- src/qt/coincontroldialog.cpp | 2 +- src/qt/transactiondesc.cpp | 2 +- src/qt/walletmodel.cpp | 4 ++-- src/rpc/blockchain.cpp | 2 +- src/rpc/net.cpp | 2 +- src/rpc/server.cpp | 2 +- src/script/standard.cpp | 2 +- src/sync.cpp | 10 +++++----- src/utilstrencodings.h | 3 --- src/validation.cpp | 6 +++--- src/wallet/rpcwallet.cpp | 4 ++-- src/wallet/wallet.cpp | 16 ++++++++-------- 15 files changed, 29 insertions(+), 32 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index ffd7f7cd0bc..899c45145e3 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -611,7 +611,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; - for (const PAIRTYPE(std::string, fs::path)& item : mapBlockFiles) { + for (const std::pair& item : mapBlockFiles) { if (atoi(item.first) == nContigCounter) { nContigCounter++; continue; diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 282dd842ffb..5f5039a1242 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1235,7 +1235,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam // however we MUST always provide at least what the remote peer needs typedef std::pair PairType; for (PairType& pair : merkleBlock.vMatchedTxn) - connman.PushMessage(pfrom, msgMaker.Make(SERIALIZE_TRANSACTION_NO_WITNESS, NetMsgType::TX, *pblock->vtx[pair.first])); + connman.PushMessage(pfrom, msgMaker.Make(SERIALIZE_TRANSACTION_NO_WITNESS, NetMsgType::TX, *block->vtx[pair.first])); } // else // no response diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp index 967933abf4e..d3ad24da018 100644 --- a/src/qt/addresstablemodel.cpp +++ b/src/qt/addresstablemodel.cpp @@ -81,7 +81,7 @@ class AddressTablePriv cachedAddressTable.clear(); { LOCK(wallet->cs_wallet); - for (const PAIRTYPE(CTxDestination, CAddressBookData)& item : wallet->mapAddressBook) + for (const std::pair& item : wallet->mapAddressBook) { const CBitcoinAddress& address = item.first; bool fMine = IsMine(*wallet, address.Get()); diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index b22bc296fe5..3ca71e7a41f 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -647,7 +647,7 @@ void CoinControlDialog::updateView() std::map > mapCoins; model->listCoins(mapCoins); - for (const PAIRTYPE(QString, std::vector)& coins : mapCoins) { + for (const std::pair>& coins : mapCoins) { CCoinControlWidgetItem *itemWalletAddress = new CCoinControlWidgetItem(); itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); QString sWalletAddress = coins.first; diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index a2a44477b79..1285a13540f 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -237,7 +237,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco strHTML += "" + tr("Output index") + ": " + QString::number(rec->getOutputIndex()) + "
"; // Message from normal bitcoin:URI (bitcoin:123...?message=example) - for (const PAIRTYPE(std::string, std::string)& r : wtx.vOrderForm) + for (const std::pair& r : wtx.vOrderForm) if (r.first == "Message") strHTML += "
" + tr("Message") + ":
" + GUIUtil::HtmlEscape(r.second, true) + "
"; diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 79d8c335ebe..a4bada878fe 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -643,8 +643,8 @@ void WalletModel::listLockedCoins(std::vector& vOutpts) void WalletModel::loadReceiveRequests(std::vector& vReceiveRequests) { LOCK(wallet->cs_wallet); - BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, wallet->mapAddressBook) - BOOST_FOREACH(const PAIRTYPE(std::string, std::string)& item2, item.second.destdata) + BOOST_FOREACH(const std::pair& item, wallet->mapAddressBook) + BOOST_FOREACH(const std::pair& item2, item.second.destdata) if (item2.first.size() > 2 && item2.first.substr(0,2) == "rr") // receive request vReceiveRequests.push_back(item2.second); } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 03ca68d641c..5ef8f376f37 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1326,7 +1326,7 @@ UniValue getchaintips(const JSONRPCRequest& request) std::set setOrphans; std::set setPrevs; - for (const PAIRTYPE(const uint256, CBlockIndex*)& item : mapBlockIndex) + for (const std::pair& item : mapBlockIndex) { if (!chainActive.Contains(item.second)) { setOrphans.insert(item.second); diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index bf0fd3202cd..1d05c5dca44 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -500,7 +500,7 @@ UniValue getnetworkinfo(const JSONRPCRequest& request) UniValue localAddresses(UniValue::VARR); { LOCK(cs_mapLocalHost); - for (const PAIRTYPE(CNetAddr, LocalServiceInfo) &item : mapLocalHost) + for (const std::pair &item : mapLocalHost) { UniValue rec(UniValue::VOBJ); rec.pushKV("address", item.first.ToString()); diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 4e1365bcef9..8c7f0e3b59a 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -199,7 +199,7 @@ std::string CRPCTable::help(const std::string& strCommand) const vCommands.push_back(make_pair(mi->second->category + mi->first, mi->second)); sort(vCommands.begin(), vCommands.end()); - for (const PAIRTYPE(string, const CRPCCommand*)& command : vCommands) + for (const std::pair& command : vCommands) { const CRPCCommand *pcmd = command.second; string strMethod = pcmd->name; diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 8bee1a3c14c..64c02feae41 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -96,7 +96,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector& tplate : mTemplates) { const CScript& script2 = tplate.second; vSolutionsRet.clear(); diff --git a/src/sync.cpp b/src/sync.cpp index 9c4446f1bca..e49d8645be9 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -79,7 +79,7 @@ static void potential_deadlock_detected(const std::pair& mismatch, { LogPrintf("POTENTIAL DEADLOCK DETECTED\n"); LogPrintf("Previous lock order was:\n"); - for (const PAIRTYPE(void*, CLockLocation) & i : s2) { + for (const std::pair & i : s2) { if (i.first == mismatch.first) { LogPrintf(" (1)"); } @@ -89,7 +89,7 @@ static void potential_deadlock_detected(const std::pair& mismatch, LogPrintf(" %s\n", i.second.ToString()); } LogPrintf("Current lock order is:\n"); - for (const PAIRTYPE(void*, CLockLocation) & i : s1) { + for (const std::pair & i : s1) { if (i.first == mismatch.first) { LogPrintf(" (1)"); } @@ -110,7 +110,7 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry) (*lockstack).push_back(std::make_pair(c, locklocation)); - for (const PAIRTYPE(void*, CLockLocation) & i : (*lockstack)) { + for (const std::pair & i : (*lockstack)) { if (i.first == c) break; @@ -144,14 +144,14 @@ void LeaveCritical() std::string LocksHeld() { std::string result; - for (const PAIRTYPE(void*, CLockLocation) & i : *lockstack) + for (const std::pair & i : *lockstack) result += i.second.ToString() + std::string("\n"); return result; } void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs) { - for (const PAIRTYPE(void*, CLockLocation) & i : *lockstack) + for (const std::pair & i : *lockstack) if (i.first == cs) return; fprintf(stderr, "Assertion failed: lock %s not held in %s:%i; locks held:\n%s", pszName, pszFile, nLine, LocksHeld().c_str()); diff --git a/src/utilstrencodings.h b/src/utilstrencodings.h index 968daad0257..d0f8cf81675 100644 --- a/src/utilstrencodings.h +++ b/src/utilstrencodings.h @@ -20,9 +20,6 @@ #define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0])) #define PAIRTYPE(t1, t2) std::pair -/** This is needed because the foreach macro can't get over the comma in pair */ -#define PAIRTYPE(t1, t2) std::pair - /** Used by SanitizeString() */ enum SafeChars { diff --git a/src/validation.cpp b/src/validation.cpp index 1235529c7b1..a3f55de2328 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3655,13 +3655,13 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams) // Calculate nChainWork std::vector > vSortedByHeight; vSortedByHeight.reserve(mapBlockIndex.size()); - for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex) + for (const std::pair& item : mapBlockIndex) { CBlockIndex* pindex = item.second; vSortedByHeight.push_back(std::make_pair(pindex->nHeight, pindex)); } sort(vSortedByHeight.begin(), vSortedByHeight.end()); - for (const PAIRTYPE(int, CBlockIndex*)& item : vSortedByHeight) + for (const std::pair& item : vSortedByHeight) { CBlockIndex* pindex = item.second; pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + GetBlockProof(*pindex); @@ -3715,7 +3715,7 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams) // Check presence of blk files LogPrintf("Checking all blk files are present...\n"); std::set setBlkDataFiles; - for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex) + for (const std::pair& item : mapBlockIndex) { CBlockIndex* pindex = item.second; if (pindex->nStatus & BLOCK_HAVE_DATA) { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a6416b46f10..cd250a7d68a 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -94,7 +94,7 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry) } entry.pushKV("bip125-replaceable", rbfStatus); - for (const PAIRTYPE(string,string)& item : wtx.mapValue) + for (const std::pair& item : wtx.mapValue) entry.pushKV(item.first, item.second); } @@ -1832,7 +1832,7 @@ UniValue listaccounts(const JSONRPCRequest& request) mapAccountBalances[entry.strAccount] += entry.nCreditDebit; UniValue ret(UniValue::VOBJ); - for (const PAIRTYPE(string, CAmount)& accountBalance : mapAccountBalances) { + for (const std::pair& accountBalance : mapAccountBalances) { ret.pushKV(accountBalance.first, ValueFromAmount(accountBalance.second)); } return ret; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 04d37f6e68f..ef636b97712 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -852,7 +852,7 @@ void CWallet::MarkDirty() { { LOCK(cs_wallet); - for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet) + for (std::pair& item : mapWallet) item.second.MarkDirty(); } } @@ -1575,7 +1575,7 @@ void CWallet::ReacceptWalletTransactions() std::map mapSorted; // Sort pending wallet transactions based on their initial wallet insertion order - for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet) + for (std::pair& item : mapWallet) { const uint256& wtxid = item.first; CWalletTx& wtx = item.second; @@ -1589,7 +1589,7 @@ void CWallet::ReacceptWalletTransactions() } // Try to add wallet transactions to memory pool - for (PAIRTYPE(const int64_t, CWalletTx*)& item : mapSorted) + for (std::pair& item : mapSorted) { CWalletTx& wtx = *(item.second); @@ -1848,8 +1848,8 @@ std::vector CWallet::ResendWalletTransactionsBefore(int64_t nTime, CCon LOCK(cs_wallet); // Sort them in chronological order - multimap mapSorted; - for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet) + std::multimap mapSorted; + for (std::pair& item : mapWallet) { CWalletTx& wtx = item.second; // Don't rebroadcast if newer than nTime: @@ -1857,7 +1857,7 @@ std::vector CWallet::ResendWalletTransactionsBefore(int64_t nTime, CCon continue; mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx)); } - for (PAIRTYPE(const unsigned int, CWalletTx*)& item : mapSorted) + for (std::pair& item : mapSorted) { CWalletTx& wtx = *item.second; if (wtx.RelayWalletTransaction(connman)) @@ -3048,7 +3048,7 @@ bool CWallet::DelAddressBook(const CTxDestination& address) { // Delete destdata tuples associated with address std::string strAddress = CBitcoinAddress(address).ToString(); - for (const PAIRTYPE(string, string) &item : mapAddressBook[address].destdata) + for (const std::pair &item : mapAddressBook[address].destdata) { CWalletDB(strWalletFile).EraseDestData(strAddress, item.first); } @@ -3387,7 +3387,7 @@ std::set CWallet::GetAccountAddresses(const std::string& strAcco { LOCK(cs_wallet); set result; - for (const PAIRTYPE(CTxDestination, CAddressBookData)& item : mapAddressBook) + for (const std::pair& item : mapAddressBook) { const CTxDestination& address = item.first; const string& strName = item.second.name;