mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 15:04:44 +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,
|
modernize-use-nullptr,
|
||||||
performance-for-range-copy,
|
performance-for-range-copy,
|
||||||
performance-move-const-arg,
|
performance-move-const-arg,
|
||||||
|
performance-no-automatic-move,
|
||||||
performance-unnecessary-copy-initialization,
|
performance-unnecessary-copy-initialization,
|
||||||
readability-redundant-declaration,
|
readability-redundant-declaration,
|
||||||
readability-redundant-string-init,
|
readability-redundant-string-init,
|
||||||
|
@ -19,6 +20,7 @@ modernize-use-default-member-init,
|
||||||
modernize-use-nullptr,
|
modernize-use-nullptr,
|
||||||
performance-for-range-copy,
|
performance-for-range-copy,
|
||||||
performance-move-const-arg,
|
performance-move-const-arg,
|
||||||
|
performance-no-automatic-move,
|
||||||
performance-unnecessary-copy-initialization,
|
performance-unnecessary-copy-initialization,
|
||||||
readability-redundant-declaration,
|
readability-redundant-declaration,
|
||||||
readability-redundant-string-init,
|
readability-redundant-string-init,
|
||||||
|
|
|
@ -1112,7 +1112,7 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::SelectTriedCollision()
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
Check();
|
Check();
|
||||||
const auto ret = SelectTriedCollision_();
|
auto ret = SelectTriedCollision_();
|
||||||
Check();
|
Check();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1121,7 +1121,7 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::Select(bool newOnly) const
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
Check();
|
Check();
|
||||||
const auto addrRet = Select_(newOnly);
|
auto addrRet = Select_(newOnly);
|
||||||
Check();
|
Check();
|
||||||
return addrRet;
|
return addrRet;
|
||||||
}
|
}
|
||||||
|
@ -1130,7 +1130,7 @@ std::vector<CAddress> AddrManImpl::GetAddr(size_t max_addresses, size_t max_pct,
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
Check();
|
Check();
|
||||||
const auto addresses = GetAddr_(max_addresses, max_pct, network);
|
auto addresses = GetAddr_(max_addresses, max_pct, network);
|
||||||
Check();
|
Check();
|
||||||
return addresses;
|
return addresses;
|
||||||
}
|
}
|
||||||
|
|
|
@ -822,7 +822,7 @@ static UniValue CallRPC(BaseRequestHandler* rh, const std::string& strMethod, co
|
||||||
UniValue valReply(UniValue::VSTR);
|
UniValue valReply(UniValue::VSTR);
|
||||||
if (!valReply.read(response.body))
|
if (!valReply.read(response.body))
|
||||||
throw std::runtime_error("couldn't parse reply from server");
|
throw std::runtime_error("couldn't parse reply from server");
|
||||||
const UniValue reply = rh->ProcessReply(valReply);
|
UniValue reply = rh->ProcessReply(valReply);
|
||||||
if (reply.empty())
|
if (reply.empty())
|
||||||
throw std::runtime_error("expected reply to have result, error and id properties");
|
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
|
QColor PlatformStyle::SingleColor() const
|
||||||
{
|
{
|
||||||
if (colorizeIcons) {
|
if (colorizeIcons) {
|
||||||
const QColor colorHighlightBg(QApplication::palette().color(QPalette::Highlight));
|
QColor colorHighlightBg(QApplication::palette().color(QPalette::Highlight));
|
||||||
const QColor colorHighlightFg(QApplication::palette().color(QPalette::HighlightedText));
|
QColor colorHighlightFg(QApplication::palette().color(QPalette::HighlightedText));
|
||||||
const QColor colorText(QApplication::palette().color(QPalette::WindowText));
|
const QColor colorText(QApplication::palette().color(QPalette::WindowText));
|
||||||
const int colorTextLightness = colorText.lightness();
|
const int colorTextLightness = colorText.lightness();
|
||||||
if (abs(colorHighlightBg.lightness() - colorTextLightness) < abs(colorHighlightFg.lightness() - colorTextLightness)) {
|
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())) {
|
if (request.mode == JSONRPCRequest::GET_HELP || !IsValidNumArgs(request.params.size())) {
|
||||||
throw std::runtime_error(ToString());
|
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)) {
|
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); }));
|
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) {
|
for (int i = 0; i < num_out; ++i) {
|
||||||
tx_mut.vout.emplace_back(amount_out, P2WSH_OP_TRUE);
|
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
|
// Restore previously removed outpoints
|
||||||
for (const auto& in : tx->vin) {
|
for (const auto& in : tx->vin) {
|
||||||
Assert(outpoints_rbf.insert(in.prevout).second);
|
Assert(outpoints_rbf.insert(in.prevout).second);
|
||||||
|
|
|
@ -69,7 +69,7 @@ FUZZ_TARGET_INIT(txorphan, initialize_orphanage)
|
||||||
for (auto& in : tx_mut.vin) {
|
for (auto& in : tx_mut.vin) {
|
||||||
outpoints.push_back(in.prevout);
|
outpoints.push_back(in.prevout);
|
||||||
}
|
}
|
||||||
const auto new_tx = MakeTransactionRef(tx_mut);
|
auto new_tx = MakeTransactionRef(tx_mut);
|
||||||
// add newly constructed transaction to outpoints
|
// add newly constructed transaction to outpoints
|
||||||
for (uint32_t i = 0; i < num_out; i++) {
|
for (uint32_t i = 0; i < num_out; i++) {
|
||||||
outpoints.emplace_back(new_tx->GetHash(), i);
|
outpoints.emplace_back(new_tx->GetHash(), i);
|
||||||
|
|
|
@ -321,7 +321,7 @@ CBlock TestChain100Setup::CreateAndProcessBlock(
|
||||||
chainstate = &Assert(m_node.chainman)->ActiveChainstate();
|
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);
|
std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(block);
|
||||||
Assert(m_node.chainman)->ProcessNewBlock(shared_pblock, true, true, nullptr);
|
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;
|
std::vector<COutPoint> coins_to_uncache;
|
||||||
auto args = MemPoolAccept::ATMPArgs::SingleAccept(chainparams, accept_time, bypass_limits, coins_to_uncache, test_accept);
|
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) {
|
if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) {
|
||||||
// Remove coins that were not present in the coins cache before calling
|
// 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
|
// 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;
|
std::vector<COutPoint> coins_to_uncache;
|
||||||
const CChainParams& chainparams = active_chainstate.m_chainman.GetParams();
|
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);
|
AssertLockHeld(cs_main);
|
||||||
if (test_accept) {
|
if (test_accept) {
|
||||||
auto args = MemPoolAccept::ATMPArgs::PackageTestAccept(chainparams, GetTime(), coins_to_uncache);
|
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;
|
std::string wallet_name;
|
||||||
if (GetWalletNameFromJSONRPCRequest(request, 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");
|
if (!pwallet) throw JSONRPCError(RPC_WALLET_NOT_FOUND, "Requested wallet does not exist or is not loaded");
|
||||||
return pwallet;
|
return pwallet;
|
||||||
}
|
}
|
||||||
|
|
|
@ -941,7 +941,7 @@ static std::optional<SelectionResult> select_coins(const CAmount& target, const
|
||||||
|
|
||||||
auto available_coins = coin_setup(*wallet);
|
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) {
|
if (result) {
|
||||||
const auto signedTxSize = 10 + 34 + 68 * result->GetInputSet().size(); // static header size + output size + inputs size (P2WPKH)
|
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);
|
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);
|
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) {
|
if (!wallet) {
|
||||||
error = Untranslated("Wallet loading failed.") + Untranslated(" ") + error;
|
error = Untranslated("Wallet loading failed.") + Untranslated(" ") + error;
|
||||||
status = DatabaseStatus::FAILED_LOAD;
|
status = DatabaseStatus::FAILED_LOAD;
|
||||||
|
@ -381,7 +381,7 @@ std::shared_ptr<CWallet> CreateWallet(WalletContext& context, const std::string&
|
||||||
|
|
||||||
// Make the wallet
|
// Make the wallet
|
||||||
context.chain->initMessage(_("Loading wallet…").translated);
|
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) {
|
if (!wallet) {
|
||||||
error = Untranslated("Wallet creation failed.") + Untranslated(" ") + error;
|
error = Untranslated("Wallet creation failed.") + Untranslated(" ") + error;
|
||||||
status = DatabaseStatus::FAILED_CREATE;
|
status = DatabaseStatus::FAILED_CREATE;
|
||||||
|
@ -2884,7 +2884,7 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
|
||||||
const auto start{SteadyClock::now()};
|
const auto start{SteadyClock::now()};
|
||||||
// TODO: Can't use std::make_shared because we need a custom deleter but
|
// TODO: Can't use std::make_shared because we need a custom deleter but
|
||||||
// should be possible to use std::allocate_shared.
|
// 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;
|
bool rescan_required = false;
|
||||||
DBErrors nLoadWalletRet = walletInstance->LoadWallet();
|
DBErrors nLoadWalletRet = walletInstance->LoadWallet();
|
||||||
if (nLoadWalletRet != DBErrors::LOAD_OK) {
|
if (nLoadWalletRet != DBErrors::LOAD_OK) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue