Skip to content

Commit

Permalink
Don't use pass by reference to const for cheaply-copied types (bool,
Browse files Browse the repository at this point in the history
char, etc.).
  • Loading branch information
practicalswift authored and random-zebra committed Jul 25, 2021
1 parent 4c5fe36 commit c19401b
Show file tree
Hide file tree
Showing 21 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/legacy/validation_zerocoin_legacy.cpp
Expand Up @@ -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) :
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/coldstakingmodel.cpp
Expand Up @@ -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<CTxDestination> addresses;
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/coldstakingmodel.h
Expand Up @@ -86,7 +86,7 @@ public Q_SLOTS:
QList<CSDelegation> 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
4 changes: 2 additions & 2 deletions src/qt/pivx/coldstakingwidget.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/qt/pivx/coldstakingwidget.h
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/dashboardwidget.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/dashboardwidget.h
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/settings/settingsexportcsv.cpp
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/settings/settingsexportcsv.h
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/topbar.cpp
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/topbar.h
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/qt/transactiontablemodel.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/qt/walletmodel.cpp
Expand Up @@ -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 ";
Expand Down
4 changes: 2 additions & 2 deletions src/streams.h
Expand Up @@ -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; }

Expand Down
6 changes: 3 additions & 3 deletions src/txdb.cpp
Expand Up @@ -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)));
}
Expand Down
6 changes: 3 additions & 3 deletions src/txdb.h
Expand Up @@ -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();
};

Expand Down
4 changes: 2 additions & 2 deletions src/wallet/rpcdump.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/scriptpubkeyman.cpp
Expand Up @@ -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 = "";
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/scriptpubkeyman.h
Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions src/wallet/wallet.cpp
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down Expand Up @@ -1820,7 +1820,7 @@ void CWalletTx::GetAmounts(std::list<COutputEntry>& listReceived,
}
}

bool CWallet::Upgrade(std::string& error, const int& prevVersion)
bool CWallet::Upgrade(std::string& error, const int prevVersion)
{
LOCK2(cs_wallet, cs_KeyStore);

Expand Down Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions src/wallet/wallet.h
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -1207,7 +1207,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
boost::signals2::signal<void(bool fHaveWatchOnly)> NotifyWatchonlyChanged;

/** notify wallet file backed up */
boost::signals2::signal<void (const bool& fSuccess, const std::string& filename)> NotifyWalletBacked;
boost::signals2::signal<void (const bool fSuccess, const std::string& filename)> NotifyWalletBacked;

/** notify stake-split threshold changed */
boost::signals2::signal<void (const CAmount stakeSplitThreshold)> NotifySSTChanged;
Expand Down

0 comments on commit c19401b

Please sign in to comment.