mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
clang-tidy: Add performance-no-automatic-move
check
https://clang.llvm.org/extra/clang-tidy/checks/performance/no-automatic-move.html
This commit is contained in:
parent
e9262ea32a
commit
9567bfeab9
12 changed files with 19 additions and 17 deletions
|
@ -7,6 +7,7 @@ modernize-use-default-member-init,
|
|||
modernize-use-nullptr,
|
||||
performance-for-range-copy,
|
||||
performance-move-const-arg,
|
||||
performance-no-automatic-move,
|
||||
performance-unnecessary-copy-initialization,
|
||||
readability-redundant-declaration,
|
||||
readability-redundant-string-init,
|
||||
|
@ -19,6 +20,7 @@ modernize-use-default-member-init,
|
|||
modernize-use-nullptr,
|
||||
performance-for-range-copy,
|
||||
performance-move-const-arg,
|
||||
performance-no-automatic-move,
|
||||
performance-unnecessary-copy-initialization,
|
||||
readability-redundant-declaration,
|
||||
readability-redundant-string-init,
|
||||
|
|
|
@ -1112,7 +1112,7 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::SelectTriedCollision()
|
|||
{
|
||||
LOCK(cs);
|
||||
Check();
|
||||
const auto ret = SelectTriedCollision_();
|
||||
auto ret = SelectTriedCollision_();
|
||||
Check();
|
||||
return ret;
|
||||
}
|
||||
|
@ -1121,7 +1121,7 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::Select(bool newOnly) const
|
|||
{
|
||||
LOCK(cs);
|
||||
Check();
|
||||
const auto addrRet = Select_(newOnly);
|
||||
auto addrRet = Select_(newOnly);
|
||||
Check();
|
||||
return addrRet;
|
||||
}
|
||||
|
@ -1130,7 +1130,7 @@ std::vector<CAddress> AddrManImpl::GetAddr(size_t max_addresses, size_t max_pct,
|
|||
{
|
||||
LOCK(cs);
|
||||
Check();
|
||||
const auto addresses = GetAddr_(max_addresses, max_pct, network);
|
||||
auto addresses = GetAddr_(max_addresses, max_pct, network);
|
||||
Check();
|
||||
return addresses;
|
||||
}
|
||||
|
|
|
@ -822,7 +822,7 @@ static UniValue CallRPC(BaseRequestHandler* rh, const std::string& strMethod, co
|
|||
UniValue valReply(UniValue::VSTR);
|
||||
if (!valReply.read(response.body))
|
||||
throw std::runtime_error("couldn't parse reply from server");
|
||||
const UniValue reply = rh->ProcessReply(valReply);
|
||||
UniValue reply = rh->ProcessReply(valReply);
|
||||
if (reply.empty())
|
||||
throw std::runtime_error("expected reply to have result, error and id properties");
|
||||
|
||||
|
|
|
@ -83,8 +83,8 @@ QColor PlatformStyle::TextColor() const
|
|||
QColor PlatformStyle::SingleColor() const
|
||||
{
|
||||
if (colorizeIcons) {
|
||||
const QColor colorHighlightBg(QApplication::palette().color(QPalette::Highlight));
|
||||
const QColor colorHighlightFg(QApplication::palette().color(QPalette::HighlightedText));
|
||||
QColor colorHighlightBg(QApplication::palette().color(QPalette::Highlight));
|
||||
QColor colorHighlightFg(QApplication::palette().color(QPalette::HighlightedText));
|
||||
const QColor colorText(QApplication::palette().color(QPalette::WindowText));
|
||||
const int colorTextLightness = colorText.lightness();
|
||||
if (abs(colorHighlightBg.lightness() - colorTextLightness) < abs(colorHighlightFg.lightness() - colorTextLightness)) {
|
||||
|
|
|
@ -579,7 +579,7 @@ UniValue RPCHelpMan::HandleRequest(const JSONRPCRequest& request) const
|
|||
if (request.mode == JSONRPCRequest::GET_HELP || !IsValidNumArgs(request.params.size())) {
|
||||
throw std::runtime_error(ToString());
|
||||
}
|
||||
const UniValue ret = m_fun(*this, request);
|
||||
UniValue ret = m_fun(*this, request);
|
||||
if (gArgs.GetBoolArg("-rpcdoccheck", DEFAULT_RPC_DOC_CHECK)) {
|
||||
CHECK_NONFATAL(std::any_of(m_results.m_results.begin(), m_results.m_results.end(), [&ret](const RPCResult& res) { return res.MatchesType(ret); }));
|
||||
}
|
||||
|
|
|
@ -211,7 +211,7 @@ FUZZ_TARGET_INIT(tx_pool_standard, initialize_tx_pool)
|
|||
for (int i = 0; i < num_out; ++i) {
|
||||
tx_mut.vout.emplace_back(amount_out, P2WSH_OP_TRUE);
|
||||
}
|
||||
const auto tx = MakeTransactionRef(tx_mut);
|
||||
auto tx = MakeTransactionRef(tx_mut);
|
||||
// Restore previously removed outpoints
|
||||
for (const auto& in : tx->vin) {
|
||||
Assert(outpoints_rbf.insert(in.prevout).second);
|
||||
|
|
|
@ -69,7 +69,7 @@ FUZZ_TARGET_INIT(txorphan, initialize_orphanage)
|
|||
for (auto& in : tx_mut.vin) {
|
||||
outpoints.push_back(in.prevout);
|
||||
}
|
||||
const auto new_tx = MakeTransactionRef(tx_mut);
|
||||
auto new_tx = MakeTransactionRef(tx_mut);
|
||||
// add newly constructed transaction to outpoints
|
||||
for (uint32_t i = 0; i < num_out; i++) {
|
||||
outpoints.emplace_back(new_tx->GetHash(), i);
|
||||
|
|
|
@ -321,7 +321,7 @@ CBlock TestChain100Setup::CreateAndProcessBlock(
|
|||
chainstate = &Assert(m_node.chainman)->ActiveChainstate();
|
||||
}
|
||||
|
||||
const CBlock block = this->CreateBlock(txns, scriptPubKey, *chainstate);
|
||||
CBlock block = this->CreateBlock(txns, scriptPubKey, *chainstate);
|
||||
std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(block);
|
||||
Assert(m_node.chainman)->ProcessNewBlock(shared_pblock, true, true, nullptr);
|
||||
|
||||
|
|
|
@ -1411,7 +1411,7 @@ MempoolAcceptResult AcceptToMemoryPool(Chainstate& active_chainstate, const CTra
|
|||
|
||||
std::vector<COutPoint> coins_to_uncache;
|
||||
auto args = MemPoolAccept::ATMPArgs::SingleAccept(chainparams, accept_time, bypass_limits, coins_to_uncache, test_accept);
|
||||
const MempoolAcceptResult result = MemPoolAccept(pool, active_chainstate).AcceptSingleTransaction(tx, args);
|
||||
MempoolAcceptResult result = MemPoolAccept(pool, active_chainstate).AcceptSingleTransaction(tx, args);
|
||||
if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) {
|
||||
// Remove coins that were not present in the coins cache before calling
|
||||
// AcceptSingleTransaction(); this is to prevent memory DoS in case we receive a large
|
||||
|
@ -1436,7 +1436,7 @@ PackageMempoolAcceptResult ProcessNewPackage(Chainstate& active_chainstate, CTxM
|
|||
|
||||
std::vector<COutPoint> coins_to_uncache;
|
||||
const CChainParams& chainparams = active_chainstate.m_chainman.GetParams();
|
||||
const auto result = [&]() EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
|
||||
auto result = [&]() EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
|
||||
AssertLockHeld(cs_main);
|
||||
if (test_accept) {
|
||||
auto args = MemPoolAccept::ATMPArgs::PackageTestAccept(chainparams, GetTime(), coins_to_uncache);
|
||||
|
|
|
@ -75,7 +75,7 @@ std::shared_ptr<CWallet> GetWalletForJSONRPCRequest(const JSONRPCRequest& reques
|
|||
|
||||
std::string wallet_name;
|
||||
if (GetWalletNameFromJSONRPCRequest(request, wallet_name)) {
|
||||
const std::shared_ptr<CWallet> pwallet = GetWallet(context, wallet_name);
|
||||
std::shared_ptr<CWallet> pwallet = GetWallet(context, wallet_name);
|
||||
if (!pwallet) throw JSONRPCError(RPC_WALLET_NOT_FOUND, "Requested wallet does not exist or is not loaded");
|
||||
return pwallet;
|
||||
}
|
||||
|
|
|
@ -941,7 +941,7 @@ static std::optional<SelectionResult> select_coins(const CAmount& target, const
|
|||
|
||||
auto available_coins = coin_setup(*wallet);
|
||||
|
||||
const auto result = SelectCoins(*wallet, available_coins, /*pre_set_inputs=*/ {}, target, cc, cs_params);
|
||||
auto result = SelectCoins(*wallet, available_coins, /*pre_set_inputs=*/ {}, target, cc, cs_params);
|
||||
if (result) {
|
||||
const auto signedTxSize = 10 + 34 + 68 * result->GetInputSet().size(); // static header size + output size + inputs size (P2WPKH)
|
||||
BOOST_CHECK_LE(signedTxSize * WITNESS_SCALE_FACTOR, MAX_STANDARD_TX_WEIGHT);
|
||||
|
|
|
@ -241,7 +241,7 @@ std::shared_ptr<CWallet> LoadWalletInternal(WalletContext& context, const std::s
|
|||
}
|
||||
|
||||
context.chain->initMessage(_("Loading wallet…").translated);
|
||||
const std::shared_ptr<CWallet> wallet = CWallet::Create(context, name, std::move(database), options.create_flags, error, warnings);
|
||||
std::shared_ptr<CWallet> wallet = CWallet::Create(context, name, std::move(database), options.create_flags, error, warnings);
|
||||
if (!wallet) {
|
||||
error = Untranslated("Wallet loading failed.") + Untranslated(" ") + error;
|
||||
status = DatabaseStatus::FAILED_LOAD;
|
||||
|
@ -381,7 +381,7 @@ std::shared_ptr<CWallet> CreateWallet(WalletContext& context, const std::string&
|
|||
|
||||
// Make the wallet
|
||||
context.chain->initMessage(_("Loading wallet…").translated);
|
||||
const std::shared_ptr<CWallet> wallet = CWallet::Create(context, name, std::move(database), wallet_creation_flags, error, warnings);
|
||||
std::shared_ptr<CWallet> wallet = CWallet::Create(context, name, std::move(database), wallet_creation_flags, error, warnings);
|
||||
if (!wallet) {
|
||||
error = Untranslated("Wallet creation failed.") + Untranslated(" ") + error;
|
||||
status = DatabaseStatus::FAILED_CREATE;
|
||||
|
@ -2884,7 +2884,7 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
|
|||
const auto start{SteadyClock::now()};
|
||||
// TODO: Can't use std::make_shared because we need a custom deleter but
|
||||
// should be possible to use std::allocate_shared.
|
||||
const std::shared_ptr<CWallet> walletInstance(new CWallet(chain, name, args, std::move(database)), ReleaseWallet);
|
||||
std::shared_ptr<CWallet> walletInstance(new CWallet(chain, name, args, std::move(database)), ReleaseWallet);
|
||||
bool rescan_required = false;
|
||||
DBErrors nLoadWalletRet = walletInstance->LoadWallet();
|
||||
if (nLoadWalletRet != DBErrors::LOAD_OK) {
|
||||
|
|
Loading…
Add table
Reference in a new issue