Merge bitcoin/bitcoin#31650: refactor: Avoid copies by using const references or by move-construction
fa64d8424brefactor: Enforce readability-avoid-const-params-in-decls (MarcoFalke)faf0c2d942refactor: Avoid copies by using const references or by move-construction (MarcoFalke) Pull request description: Top level `const` in declarations is problematic for many reasons: * It is often a typo, where one wanted to denote a const reference. For example `bool PSBTInputSignedAndVerified(const PartiallySignedTransaction psbt, ...` is missing the `&`. This will create a redundant copy of the value. * In constructors it prevents move construction. * It can incorrectly imply some data is const, like in an imaginary example `std::span<int> Shuffle(const std::span<int>);`, where the `int`s are *not* const. * The compiler ignores the `const` from the declaration in the implementation. * It isn't used consistently anyway, not even on the same line. Fix some issues by: * Using a const reference to avoid a copy, where read-only of the value is intended. This is only done for values that may be expensive to copy. * Using move-construction to avoid a copy * Applying `readability-avoid-const-params-in-decls` via clang-tidy ACKs for top commit: l0rinc: diff reACKfa64d8424bhebasto: ACKfa64d8424b, I have reviewed the code and it looks OK. sedited: ACKfa64d8424bTree-SHA512: 293c000b4ebf8fdcc75259eb0283a2e4e7892c73facfb5c3182464d6cb6a868b7f4a6682d664426bf2edecd665cf839d790bef0bae43a8c3bf1ddfdd3d068d38
This commit is contained in:
56 files changed
+97
-94
No files matched your search
@@ -70,7 +70,7 @@ public:
|
||||
/* Add an address to the model.
|
||||
Returns the added address on success, and an empty string otherwise.
|
||||
*/
|
||||
QString addRow(const QString &type, const QString &label, const QString &address, const OutputType address_type);
|
||||
QString addRow(const QString& type, const QString& label, const QString& address, OutputType address_type);
|
||||
|
||||
/** Look up label for address in address book, if not found return empty string. */
|
||||
QString labelForAddress(const QString &address) const;
|
||||
|
||||
@@ -16,7 +16,7 @@ class NetworkStyle
|
||||
{
|
||||
public:
|
||||
/** Get style associated with provided network id, or 0 if not known */
|
||||
static const NetworkStyle* instantiate(const ChainType networkId);
|
||||
static const NetworkStyle* instantiate(ChainType networkId);
|
||||
|
||||
const QString &getAppName() const { return appName; }
|
||||
const QIcon &getAppIcon() const { return appIcon; }
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
const QString &getTitleAddText() const { return titleAddText; }
|
||||
|
||||
private:
|
||||
NetworkStyle(const QString &appName, const int iconColorHueShift, const int iconColorSaturationReduction, const char *titleAddText);
|
||||
NetworkStyle(const QString& appName, int iconColorHueShift, int iconColorSaturationReduction, const char* titleAddText);
|
||||
|
||||
QString appName;
|
||||
QIcon appIcon;
|
||||
|
||||
+4
-4
@@ -48,7 +48,7 @@ public:
|
||||
explicit RPCConsole(interfaces::Node& node, const PlatformStyle *platformStyle, QWidget *parent);
|
||||
~RPCConsole();
|
||||
|
||||
static bool RPCParseCommandLine(interfaces::Node* node, std::string &strResult, const std::string &strCommand, bool fExecute, std::string * const pstrFilteredOut = nullptr, const QString& wallet_name = {});
|
||||
static bool RPCParseCommandLine(interfaces::Node* node, std::string& strResult, const std::string& strCommand, bool fExecute, std::string* pstrFilteredOut = nullptr, const QString& wallet_name = {});
|
||||
static bool RPCExecuteCommandLine(interfaces::Node& node, std::string &strResult, const std::string &strCommand, std::string * const pstrFilteredOut = nullptr, const QString& wallet_name = {}) {
|
||||
return RPCParseCommandLine(&node, strResult, strCommand, true, pstrFilteredOut, wallet_name);
|
||||
}
|
||||
@@ -56,8 +56,8 @@ public:
|
||||
void setClientModel(ClientModel *model = nullptr, int bestblock_height = 0, int64_t bestblock_date = 0, double verification_progress = 0.0);
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
void addWallet(WalletModel* const walletModel);
|
||||
void removeWallet(WalletModel* const walletModel);
|
||||
void addWallet(WalletModel* walletModel);
|
||||
void removeWallet(WalletModel* walletModel);
|
||||
#endif // ENABLE_WALLET
|
||||
|
||||
enum MessageClass {
|
||||
@@ -138,7 +138,7 @@ public Q_SLOTS:
|
||||
void setTabFocus(enum TabTypes tabType);
|
||||
#ifdef ENABLE_WALLET
|
||||
/** Set the current (ie - active) wallet */
|
||||
void setCurrentWallet(WalletModel* const wallet_model);
|
||||
void setCurrentWallet(WalletModel* wallet_model);
|
||||
#endif // ENABLE_WALLET
|
||||
|
||||
private:
|
||||
|
||||
Reference in new issue
Block a user