Skip to content

Commit 3305972

Browse files
committed
refactor: Fix remaining clang-tidy performance-unnecessary-copy-initialization errors
1 parent 2638fdb commit 3305972

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/bench/sign_transaction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static void SignTransactionSingleInput(benchmark::Bench& bench, InputType input_
6262
bench.minEpochIterations(100).run([&] {
6363
CMutableTransaction tx{unsigned_tx};
6464
std::map<COutPoint, Coin> coins;
65-
CScript prev_spk = prev_spks[(iter++) % prev_spks.size()];
65+
const CScript& prev_spk = prev_spks[(iter++) % prev_spks.size()];
6666
coins[prevout] = Coin(CTxOut(10000, prev_spk), /*nHeightIn=*/100, /*fCoinBaseIn=*/false);
6767
std::map<int, bilingual_str> input_errors;
6868
bool complete = SignTransaction(tx, &keystore, coins, SIGHASH_ALL, input_errors);

src/bitcoin-tx.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ static void MutateTxAddOutAddr(CMutableTransaction& tx, const std::string& strIn
304304
CAmount value = ExtractAndValidateValue(vStrInputParts[0]);
305305

306306
// extract and validate ADDRESS
307-
std::string strAddr = vStrInputParts[1];
307+
const std::string& strAddr = vStrInputParts[1];
308308
CTxDestination destination = DecodeDestination(strAddr);
309309
if (!IsValidDestination(destination)) {
310310
throw std::runtime_error("invalid TX output address");
@@ -337,7 +337,7 @@ static void MutateTxAddOutPubKey(CMutableTransaction& tx, const std::string& str
337337
bool bSegWit = false;
338338
bool bScriptHash = false;
339339
if (vStrInputParts.size() == 3) {
340-
std::string flags = vStrInputParts[2];
340+
const std::string& flags = vStrInputParts[2];
341341
bSegWit = (flags.find('W') != std::string::npos);
342342
bScriptHash = (flags.find('S') != std::string::npos);
343343
}
@@ -398,7 +398,7 @@ static void MutateTxAddOutMultiSig(CMutableTransaction& tx, const std::string& s
398398
bool bSegWit = false;
399399
bool bScriptHash = false;
400400
if (vStrInputParts.size() == numkeys + 4) {
401-
std::string flags = vStrInputParts.back();
401+
const std::string& flags = vStrInputParts.back();
402402
bSegWit = (flags.find('W') != std::string::npos);
403403
bScriptHash = (flags.find('S') != std::string::npos);
404404
}
@@ -473,14 +473,14 @@ static void MutateTxAddOutScript(CMutableTransaction& tx, const std::string& str
473473
CAmount value = ExtractAndValidateValue(vStrInputParts[0]);
474474

475475
// extract and validate script
476-
std::string strScript = vStrInputParts[1];
476+
const std::string& strScript = vStrInputParts[1];
477477
CScript scriptPubKey = ParseScript(strScript);
478478

479479
// Extract FLAGS
480480
bool bSegWit = false;
481481
bool bScriptHash = false;
482482
if (vStrInputParts.size() == 3) {
483-
std::string flags = vStrInputParts.back();
483+
const std::string& flags = vStrInputParts.back();
484484
bSegWit = (flags.find('W') != std::string::npos);
485485
bScriptHash = (flags.find('S') != std::string::npos);
486486
}

src/qt/bitcoinunits.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ bool BitcoinUnits::parse(Unit unit, const QString& value, CAmount* val_out)
166166
{
167167
return false; // More than one dot
168168
}
169-
QString whole = parts[0];
169+
const QString& whole = parts[0];
170170
QString decimals;
171171

172172
if(parts.size() > 1)

src/test/validation_block_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ BOOST_AUTO_TEST_CASE(processnewblock_signals_ordering)
181181
bool ignored;
182182
FastRandomContext insecure;
183183
for (int i = 0; i < 1000; i++) {
184-
auto block = blocks[insecure.randrange(blocks.size() - 1)];
184+
const auto& block = blocks[insecure.randrange(blocks.size() - 1)];
185185
Assert(m_node.chainman)->ProcessNewBlock(block, true, true, &ignored);
186186
}
187187

0 commit comments

Comments
 (0)