From c19401bd900d8dcbb2ea966be76a7181aeeee6fb Mon Sep 17 00:00:00 2001 From: practicalswift Date: Sun, 16 Jul 2017 02:07:52 +0200 Subject: [PATCH] Don't use pass by reference to const for cheaply-copied types (bool, char, etc.). --- src/legacy/validation_zerocoin_legacy.cpp | 2 +- src/qt/pivx/coldstakingmodel.cpp | 2 +- src/qt/pivx/coldstakingmodel.h | 2 +- src/qt/pivx/coldstakingwidget.cpp | 4 ++-- src/qt/pivx/coldstakingwidget.h | 4 ++-- src/qt/pivx/dashboardwidget.cpp | 2 +- src/qt/pivx/dashboardwidget.h | 2 +- src/qt/pivx/settings/settingsexportcsv.cpp | 2 +- src/qt/pivx/settings/settingsexportcsv.h | 2 +- src/qt/pivx/topbar.cpp | 2 +- src/qt/pivx/topbar.h | 2 +- src/qt/transactiontablemodel.h | 2 +- src/qt/walletmodel.cpp | 2 +- src/streams.h | 4 ++-- src/txdb.cpp | 6 +++--- src/txdb.h | 6 +++--- src/wallet/rpcdump.cpp | 4 ++-- src/wallet/scriptpubkeyman.cpp | 2 +- src/wallet/scriptpubkeyman.h | 2 +- src/wallet/wallet.cpp | 8 ++++---- src/wallet/wallet.h | 10 +++++----- 21 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/legacy/validation_zerocoin_legacy.cpp b/src/legacy/validation_zerocoin_legacy.cpp index 4038704229709..a4177abc0a56c 100644 --- a/src/legacy/validation_zerocoin_legacy.cpp +++ b/src/legacy/validation_zerocoin_legacy.cpp @@ -59,7 +59,7 @@ void DataBaseAccChecksum(const CBlockIndex* pindex, bool fWrite) arith_uint256 accPrev = UintToArith256(pindex->pprev->nAccumulatorCheckpoint); // add/remove changed checksums to/from DB for (int i = (int)libzerocoin::zerocoinDenomList.size()-1; i >= 0; i--) { - const uint32_t& nChecksum = accCurr.Get32(); + const uint32_t nChecksum = accCurr.Get32(); if (nChecksum != accPrev.Get32()) { fWrite ? zerocoinDB->WriteAccChecksum(nChecksum, libzerocoin::zerocoinDenomList[i], pindex->nHeight) : diff --git a/src/qt/pivx/coldstakingmodel.cpp b/src/qt/pivx/coldstakingmodel.cpp index 22fc9f19654c6..931a4ad75c839 100644 --- a/src/qt/pivx/coldstakingmodel.cpp +++ b/src/qt/pivx/coldstakingmodel.cpp @@ -72,7 +72,7 @@ void ColdStakingModel::refresh() } } -bool ColdStakingModel::parseCSDelegation(const CTxOut& out, CSDelegation& ret, const QString& txId, const int& utxoIndex) +bool ColdStakingModel::parseCSDelegation(const CTxOut& out, CSDelegation& ret, const QString& txId, const int utxoIndex) { txnouttype type; std::vector addresses; diff --git a/src/qt/pivx/coldstakingmodel.h b/src/qt/pivx/coldstakingmodel.h index 3f7821731100a..704ea09945e74 100644 --- a/src/qt/pivx/coldstakingmodel.h +++ b/src/qt/pivx/coldstakingmodel.h @@ -86,7 +86,7 @@ public Q_SLOTS: QList cachedDelegations; CAmount cachedAmount; - bool parseCSDelegation(const CTxOut& out, CSDelegation& ret, const QString& txId, const int& utxoIndex); + bool parseCSDelegation(const CTxOut& out, CSDelegation& ret, const QString& txId, const int utxoIndex); }; #endif // COLDSTAKINGMODEL_H diff --git a/src/qt/pivx/coldstakingwidget.cpp b/src/qt/pivx/coldstakingwidget.cpp index e11af5c960ce9..3523cc0cf6175 100644 --- a/src/qt/pivx/coldstakingwidget.cpp +++ b/src/qt/pivx/coldstakingwidget.cpp @@ -228,7 +228,7 @@ void ColdStakingWidget::loadWalletModel() } -void ColdStakingWidget::onTxArrived(const QString& hash, const bool& isCoinStake, const bool& isCSAnyType) +void ColdStakingWidget::onTxArrived(const QString& hash, const bool isCoinStake, const bool isCSAnyType) { if (isCSAnyType) { tryRefreshDelegations(); @@ -732,7 +732,7 @@ void ColdStakingWidget::onLabelClicked() ); } -void ColdStakingWidget::onLabelClicked(QString dialogTitle, const QModelIndex &index, const bool& isMyColdStakingAddresses) +void ColdStakingWidget::onLabelClicked(QString dialogTitle, const QModelIndex &index, const bool isMyColdStakingAddresses) { if (walletModel && !isShowingDialog) { isShowingDialog = true; diff --git a/src/qt/pivx/coldstakingwidget.h b/src/qt/pivx/coldstakingwidget.h index 1fc256756189d..9552ff2c118ad 100644 --- a/src/qt/pivx/coldstakingwidget.h +++ b/src/qt/pivx/coldstakingwidget.h @@ -69,7 +69,7 @@ private Q_SLOTS: void onCopyOwnerClicked(); void onAddressCopyClicked(); void onAddressEditClicked(); - void onTxArrived(const QString& hash, const bool& isCoinStake, const bool& isCSAnyType); + void onTxArrived(const QString& hash, const bool isCoinStake, const bool isCSAnyType); void onContactsClicked(bool ownerAdd); void clearAll(); void onLabelClicked(); @@ -121,7 +121,7 @@ private Q_SLOTS: void onContactsClicked(); void tryRefreshDelegations(); bool refreshDelegations(); - void onLabelClicked(QString dialogTitle, const QModelIndex &index, const bool& isMyColdStakingAddresses); + void onLabelClicked(QString dialogTitle, const QModelIndex &index, const bool isMyColdStakingAddresses); void updateStakingTotalLabel(); void sortAddresses(); void setCoinControlPayAmounts(); diff --git a/src/qt/pivx/dashboardwidget.cpp b/src/qt/pivx/dashboardwidget.cpp index dba68de27ff5e..ee8ee2a739fc8 100644 --- a/src/qt/pivx/dashboardwidget.cpp +++ b/src/qt/pivx/dashboardwidget.cpp @@ -220,7 +220,7 @@ void DashboardWidget::loadWalletModel() updateDisplayUnit(); } -void DashboardWidget::onTxArrived(const QString& hash, const bool& isCoinStake, const bool& isCSAnyType) +void DashboardWidget::onTxArrived(const QString& hash, const bool isCoinStake, const bool isCSAnyType) { showList(); if (!isVisible()) return; diff --git a/src/qt/pivx/dashboardwidget.h b/src/qt/pivx/dashboardwidget.h index f2092c92d6fbe..72eeba8b66555 100644 --- a/src/qt/pivx/dashboardwidget.h +++ b/src/qt/pivx/dashboardwidget.h @@ -122,7 +122,7 @@ private Q_SLOTS: void onSortTypeChanged(const QString& value); void updateDisplayUnit(); void showList(); - void onTxArrived(const QString& hash, const bool& isCoinStake, const bool& isCSAnyType); + void onTxArrived(const QString& hash, const bool isCoinStake, const bool isCSAnyType); #ifdef USE_QTCHARTS void windowResizeEvent(QResizeEvent* event); diff --git a/src/qt/pivx/settings/settingsexportcsv.cpp b/src/qt/pivx/settings/settingsexportcsv.cpp index 5289a2ef321ee..a7c02389a5a68 100644 --- a/src/qt/pivx/settings/settingsexportcsv.cpp +++ b/src/qt/pivx/settings/settingsexportcsv.cpp @@ -55,7 +55,7 @@ SettingsExportCSV::SettingsExportCSV(PIVXGUI* _window, QWidget *parent) : connect(ui->pushButtonAddressDocuments, &QPushButton::clicked, [this](){selectFileOutput(false);}); } -void SettingsExportCSV::selectFileOutput(const bool& isTxExport) +void SettingsExportCSV::selectFileOutput(const bool isTxExport) { QString filename = GUIUtil::getSaveFileName(this, isTxExport ? tr("Export CSV") : tr("Export Address List"), QString(), diff --git a/src/qt/pivx/settings/settingsexportcsv.h b/src/qt/pivx/settings/settingsexportcsv.h index 6708170b620a1..e22db654d4fc6 100644 --- a/src/qt/pivx/settings/settingsexportcsv.h +++ b/src/qt/pivx/settings/settingsexportcsv.h @@ -23,7 +23,7 @@ class SettingsExportCSV : public PWidget ~SettingsExportCSV(); private Q_SLOTS: - void selectFileOutput(const bool& isTxExport); + void selectFileOutput(const bool isTxExport); void exportTxes(const QString& filename); void exportAddrs(const QString& filename); diff --git a/src/qt/pivx/topbar.cpp b/src/qt/pivx/topbar.cpp index 29b9ac02355d9..69803fe68ab80 100644 --- a/src/qt/pivx/topbar.cpp +++ b/src/qt/pivx/topbar.cpp @@ -702,7 +702,7 @@ void TopBar::expandSync() } } -void TopBar::updateHDState(const bool& upgraded, const QString& upgradeError) +void TopBar::updateHDState(const bool upgraded, const QString& upgradeError) { if (upgraded) { ui->pushButtonHDUpgrade->setVisible(false); diff --git a/src/qt/pivx/topbar.h b/src/qt/pivx/topbar.h index 065a77aaaa449..8a68ce11cf2f1 100644 --- a/src/qt/pivx/topbar.h +++ b/src/qt/pivx/topbar.h @@ -51,7 +51,7 @@ public Q_SLOTS: void setNumBlocks(int count); void setStakingStatusActive(bool fActive); void updateStakingStatus(); - void updateHDState(const bool& upgraded, const QString& upgradeError); + void updateHDState(const bool upgraded, const QString& upgradeError); void showUpgradeDialog(const QString& message); Q_SIGNALS: diff --git a/src/qt/transactiontablemodel.h b/src/qt/transactiontablemodel.h index eca072cb9b662..47c8a1a75e9ca 100644 --- a/src/qt/transactiontablemodel.h +++ b/src/qt/transactiontablemodel.h @@ -83,7 +83,7 @@ class TransactionTableModel : public QAbstractTableModel bool processingQueuedTransactions() const { return fProcessingQueuedTransactions; } Q_SIGNALS: - void txArrived(const QString& hash, const bool& isCoinStake, const bool& isCSAnyType); + void txArrived(const QString& hash, const bool isCoinStake, const bool isCSAnyType); private: // Listeners diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index cee21970c4cb7..1ad6326bd1097 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -804,7 +804,7 @@ static void NotifySSTChanged(WalletModel* walletmodel, const CAmount stakeSplitT Q_EMIT walletmodel->notifySSTChanged(val); } -static void NotifyWalletBacked(WalletModel* model, const bool& fSuccess, const std::string& filename) +static void NotifyWalletBacked(WalletModel* model, const bool fSuccess, const std::string& filename) { std::string message; std::string title = "Backup "; diff --git a/src/streams.h b/src/streams.h index baa30dc048329..c2ef214bc0b34 100644 --- a/src/streams.h +++ b/src/streams.h @@ -130,8 +130,8 @@ class CBaseDataStream vch.clear(); nReadPos = 0; } - iterator insert(iterator it, const char& x = char()) { return vch.insert(it, x); } - void insert(iterator it, size_type n, const char& x) { vch.insert(it, n, x); } + iterator insert(iterator it, const char x = char()) { return vch.insert(it, x); } + void insert(iterator it, size_type n, const char x) { vch.insert(it, n, x); } value_type* data() { return vch.data() + nReadPos; } const value_type* data() const { return vch.data() + nReadPos; } diff --git a/src/txdb.cpp b/src/txdb.cpp index 6cc5c2f20475e..1fc6630c8d975 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -383,17 +383,17 @@ bool CZerocoinDB::EraseCoinSpend(const CBigNum& bnSerial) static const char LZC_ACCUMCS = 'A'; //static const char LZC_MAPSUPPLY = 'M'; // TODO: add removal for LZC_MAPSUPPLY key-value if is found in db -bool CZerocoinDB::WriteAccChecksum(const uint32_t& nChecksum, const libzerocoin::CoinDenomination denom, const int nHeight) +bool CZerocoinDB::WriteAccChecksum(const uint32_t nChecksum, const libzerocoin::CoinDenomination denom, const int nHeight) { return Write(std::make_pair(LZC_ACCUMCS, std::make_pair(nChecksum, denom)), nHeight); } -bool CZerocoinDB::ReadAccChecksum(const uint32_t& nChecksum, const libzerocoin::CoinDenomination denom, int& nHeightRet) +bool CZerocoinDB::ReadAccChecksum(const uint32_t nChecksum, const libzerocoin::CoinDenomination denom, int& nHeightRet) { return Read(std::make_pair(LZC_ACCUMCS, std::make_pair(nChecksum, denom)), nHeightRet); } -bool CZerocoinDB::EraseAccChecksum(const uint32_t& nChecksum, const libzerocoin::CoinDenomination denom) +bool CZerocoinDB::EraseAccChecksum(const uint32_t nChecksum, const libzerocoin::CoinDenomination denom) { return Erase(std::make_pair(LZC_ACCUMCS, std::make_pair(nChecksum, denom))); } diff --git a/src/txdb.h b/src/txdb.h index d87f82a63985f..354c109e02aa7 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -166,9 +166,9 @@ class CZerocoinDB : public CDBWrapper bool EraseCoinSpend(const CBigNum& bnSerial); /** Accumulators (only for zPoS IBD): [checksum, denom] --> block height **/ - bool WriteAccChecksum(const uint32_t& nChecksum, const libzerocoin::CoinDenomination denom, const int nHeight); - bool ReadAccChecksum(const uint32_t& nChecksum, const libzerocoin::CoinDenomination denom, int& nHeightRet); - bool EraseAccChecksum(const uint32_t& nChecksum, const libzerocoin::CoinDenomination denom); + bool WriteAccChecksum(const uint32_t nChecksum, const libzerocoin::CoinDenomination denom, const int nHeight); + bool ReadAccChecksum(const uint32_t nChecksum, const libzerocoin::CoinDenomination denom, int& nHeightRet); + bool EraseAccChecksum(const uint32_t nChecksum, const libzerocoin::CoinDenomination denom); bool WipeAccChecksums(); }; diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 2f25f806487e0..7cded639bd48f 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -665,8 +665,8 @@ static UniValue processImport(CWallet* const pwallet, const UniValue& data, cons const std::string& strRedeemScript = data.exists("redeemscript") ? data["redeemscript"].get_str() : ""; const UniValue& pubKeys = data.exists("pubkeys") ? data["pubkeys"].get_array() : UniValue(); const UniValue& keys = data.exists("keys") ? data["keys"].get_array() : UniValue(); - const bool& internal = data.exists("internal") ? data["internal"].get_bool() : false; - const bool& watchOnly = data.exists("watchonly") ? data["watchonly"].get_bool() : false; + const bool internal = data.exists("internal") ? data["internal"].get_bool() : false; + const bool watchOnly = data.exists("watchonly") ? data["watchonly"].get_bool() : false; const std::string& label = data.exists("label") && !internal ? data["label"].get_str() : ""; bool isScript = scriptPubKey.getType() == UniValue::VSTR; diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index bc71d877211e1..8870bd3b6ea0f 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -20,7 +20,7 @@ bool ScriptPubKeyMan::SetupGeneration(bool newKeypool, bool force, bool memOnly) return true; } -bool ScriptPubKeyMan::Upgrade(const int& prev_version, std::string& error) +bool ScriptPubKeyMan::Upgrade(const int prev_version, std::string& error) { LOCK(wallet->cs_KeyStore); error = ""; diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index f702167a5f80b..d2c81a803b8d1 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -38,7 +38,7 @@ class ScriptPubKeyMan { bool SetupGeneration(bool newKeypool = true, bool force = false, bool memOnly = false); /** Upgrades the wallet to the specified version */ - bool Upgrade(const int& prev_version, std::string& error); + bool Upgrade(const int prev_version, std::string& error); /* Returns true if the wallet can generate new keys */ bool CanGenerateKeys(); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 4499852da9e59..767d064c3b052 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1736,7 +1736,7 @@ CAmount CWalletTx::GetLockedCredit() const return nCredit; } -CAmount CWalletTx::GetImmatureWatchOnlyCredit(const bool& fUseCache) const +CAmount CWalletTx::GetImmatureWatchOnlyCredit(const bool fUseCache) const { if (IsInMainChainImmature()) { return GetCachableAmount(IMMATURE_CREDIT, ISMINE_WATCH_ONLY, !fUseCache); @@ -1745,7 +1745,7 @@ CAmount CWalletTx::GetImmatureWatchOnlyCredit(const bool& fUseCache) const return 0; } -CAmount CWalletTx::GetAvailableWatchOnlyCredit(const bool& fUseCache) const +CAmount CWalletTx::GetAvailableWatchOnlyCredit(const bool fUseCache) const { return GetAvailableCredit(fUseCache, ISMINE_WATCH_ONLY); } @@ -1820,7 +1820,7 @@ void CWalletTx::GetAmounts(std::list& listReceived, } } -bool CWallet::Upgrade(std::string& error, const int& prevVersion) +bool CWallet::Upgrade(std::string& error, const int prevVersion) { LOCK2(cs_wallet, cs_KeyStore); @@ -3611,7 +3611,7 @@ void CWallet::KeepKey(int64_t nIndex) m_spk_man->KeepDestination(nIndex); } -void CWallet::ReturnKey(int64_t nIndex, const bool& internal, const bool& staking) +void CWallet::ReturnKey(int64_t nIndex, const bool internal, const bool staking) { // Return to key pool CTxDestination address; // This is not needed for now. diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index ad5ae5260c78b..6d139214a8259 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -489,8 +489,8 @@ class CWalletTx CAmount GetAvailableCredit(bool fUseCache = true, const isminefilter& filter=ISMINE_SPENDABLE) const; // Return sum of locked coins CAmount GetLockedCredit() const; - CAmount GetImmatureWatchOnlyCredit(const bool& fUseCache = true) const; - CAmount GetAvailableWatchOnlyCredit(const bool& fUseCache = true) const; + CAmount GetImmatureWatchOnlyCredit(const bool fUseCache = true) const; + CAmount GetAvailableWatchOnlyCredit(const bool fUseCache = true) const; CAmount GetChange() const; // Shielded credit/debit/change @@ -1004,7 +1004,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface /** * Upgrade wallet to HD and Sapling if needed. Does nothing if not. */ - bool Upgrade(std::string& error, const int& prevVersion); + bool Upgrade(std::string& error, const int prevVersion); bool ActivateSaplingWallet(bool memOnly = false); int64_t RescanFromTime(int64_t startTime, const WalletRescanReserver& reserver, bool update); @@ -1094,7 +1094,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface size_t KeypoolCountExternalKeys(); bool TopUpKeyPool(unsigned int kpSize = 0); void KeepKey(int64_t nIndex); - void ReturnKey(int64_t nIndex, const bool& internal = false, const bool& staking = false); + void ReturnKey(int64_t nIndex, const bool internal = false, const bool staking = false); bool GetKeyFromPool(CPubKey& key, const uint8_t& type = HDChain::ChangeType::EXTERNAL); int64_t GetOldestKeyPoolTime(); @@ -1207,7 +1207,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface boost::signals2::signal NotifyWatchonlyChanged; /** notify wallet file backed up */ - boost::signals2::signal NotifyWalletBacked; + boost::signals2::signal NotifyWalletBacked; /** notify stake-split threshold changed */ boost::signals2::signal NotifySSTChanged;