Skip to content

Commit 08ea835

Browse files
committed
Merge bitcoin#28583: refactor: [tidy] modernize-use-emplace
fa05a72 tidy: modernize-use-emplace (MarcoFalke) Pull request description: Constructing a temporary unnamed object only to copy or move it into a container seems both verbose in code and a strict performance penalty. Fix both issues via the `modernize-use-emplace` tidy check. ACKs for top commit: Sjors: re-utACK fa05a72 hebasto: ACK fa05a72. TheCharlatan: ACK fa05a72 Tree-SHA512: 4408a094f406e7bf6c1468c2b0798f68f4d952a1253cf5b20bdc648ad7eea4a2c070051fed46d66fd37bce2ce6f85962484a1d32826b7ab8c9baba431eaa2765
2 parents 9270453 + fa05a72 commit 08ea835

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+167
-162
lines changed

src/.bear-tidy-config

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"src/crypto/ctaes",
99
"src/leveldb",
1010
"src/minisketch",
11+
"src/bench/nanobench.cpp",
12+
"src/bench/nanobench.h",
1113
"src/secp256k1"
1214
]
1315
},

src/.clang-tidy

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ bugprone-argument-comment,
55
bugprone-use-after-move,
66
misc-unused-using-decls,
77
modernize-use-default-member-init,
8+
modernize-use-emplace,
89
modernize-use-noexcept,
910
modernize-use-nullptr,
1011
performance-*,

src/addrman.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ std::vector<std::pair<AddrInfo, AddressPosition>> AddrManImpl::GetEntries_(bool
854854
/*multiplicity_in=*/from_tried ? 1 : info.nRefCount,
855855
bucket,
856856
position);
857-
infos.push_back(std::make_pair(info, location));
857+
infos.emplace_back(info, location);
858858
}
859859
}
860860
}

src/bench/block_assemble.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static void AssembleBlock(benchmark::Bench& bench)
2828
std::array<CTransactionRef, NUM_BLOCKS - COINBASE_MATURITY + 1> txs;
2929
for (size_t b{0}; b < NUM_BLOCKS; ++b) {
3030
CMutableTransaction tx;
31-
tx.vin.push_back(CTxIn{MineBlock(test_setup->m_node, P2WSH_OP_TRUE)});
31+
tx.vin.emplace_back(MineBlock(test_setup->m_node, P2WSH_OP_TRUE));
3232
tx.vin.back().scriptWitness = witness;
3333
tx.vout.emplace_back(1337, P2WSH_OP_TRUE);
3434
if (NUM_BLOCKS - b >= COINBASE_MATURITY)

src/bench/disconnected_transactions.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ static BlockTxns CreateRandomTransactions(size_t num_txns)
3636
CScript spk = CScript() << OP_TRUE;
3737
for (uint32_t i = 0; i < num_txns; ++i) {
3838
CMutableTransaction tx;
39-
tx.vin.emplace_back(CTxIn{COutPoint{prevout_hash, 0}});
40-
tx.vout.emplace_back(CTxOut{CENT, spk});
39+
tx.vin.emplace_back(COutPoint{prevout_hash, 0});
40+
tx.vout.emplace_back(CENT, spk);
4141
auto ptx{MakeTransactionRef(tx)};
4242
txns.emplace_back(ptx);
4343
prevout_hash = ptx->GetHash();

src/bench/wallet_loading.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ namespace wallet{
2020
static void AddTx(CWallet& wallet)
2121
{
2222
CMutableTransaction mtx;
23-
mtx.vout.push_back({COIN, GetScriptForDestination(*Assert(wallet.GetNewDestination(OutputType::BECH32, "")))});
24-
mtx.vin.push_back(CTxIn());
23+
mtx.vout.emplace_back(COIN, GetScriptForDestination(*Assert(wallet.GetNewDestination(OutputType::BECH32, ""))));
24+
mtx.vin.emplace_back();
2525

2626
wallet.AddToWallet(MakeTransactionRef(mtx), TxStateInactive{});
2727
}

src/common/args.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
216216
m_command.push_back(key);
217217
while (++i < argc) {
218218
// The remaining args are command args
219-
m_command.push_back(argv[i]);
219+
m_command.emplace_back(argv[i]);
220220
}
221221
break;
222222
}

src/external_signer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ bool ExternalSigner::Enumerate(const std::string& command, std::vector<ExternalS
5454
if (model_field.isStr() && model_field.getValStr() != "") {
5555
name += model_field.getValStr();
5656
}
57-
signers.push_back(ExternalSigner(command, chain, fingerprintStr, name));
57+
signers.emplace_back(command, chain, fingerprintStr, name);
5858
}
5959
return true;
6060
}

src/headerssync.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ bool HeadersSyncState::ValidateAndStoreRedownloadedHeader(const CBlockHeader& he
271271
}
272272

273273
// Store this header for later processing.
274-
m_redownloaded_headers.push_back(header);
274+
m_redownloaded_headers.emplace_back(header);
275275
m_redownload_buffer_last_height = next_height;
276276
m_redownload_buffer_last_hash = header.GetHash();
277277

src/httpserver.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ static bool ClientAllowed(const CNetAddr& netaddr)
221221
static bool InitHTTPAllowList()
222222
{
223223
rpc_allow_subnets.clear();
224-
rpc_allow_subnets.push_back(CSubNet{LookupHost("127.0.0.1", false).value(), 8}); // always allow IPv4 local subnet
225-
rpc_allow_subnets.push_back(CSubNet{LookupHost("::1", false).value()}); // always allow IPv6 localhost
224+
rpc_allow_subnets.emplace_back(LookupHost("127.0.0.1", false).value(), 8); // always allow IPv4 local subnet
225+
rpc_allow_subnets.emplace_back(LookupHost("::1", false).value()); // always allow IPv6 localhost
226226
for (const std::string& strAllow : gArgs.GetArgs("-rpcallowip")) {
227227
CSubNet subnet;
228228
LookupSubNet(strAllow, subnet);
@@ -364,8 +364,8 @@ static bool HTTPBindAddresses(struct evhttp* http)
364364

365365
// Determine what addresses to bind to
366366
if (!(gArgs.IsArgSet("-rpcallowip") && gArgs.IsArgSet("-rpcbind"))) { // Default to loopback if not allowing external IPs
367-
endpoints.push_back(std::make_pair("::1", http_port));
368-
endpoints.push_back(std::make_pair("127.0.0.1", http_port));
367+
endpoints.emplace_back("::1", http_port);
368+
endpoints.emplace_back("127.0.0.1", http_port);
369369
if (gArgs.IsArgSet("-rpcallowip")) {
370370
LogPrintf("WARNING: option -rpcallowip was specified without -rpcbind; this doesn't usually make sense\n");
371371
}
@@ -377,7 +377,7 @@ static bool HTTPBindAddresses(struct evhttp* http)
377377
uint16_t port{http_port};
378378
std::string host;
379379
SplitHostPort(strRPCBind, port, host);
380-
endpoints.push_back(std::make_pair(host, port));
380+
endpoints.emplace_back(host, port);
381381
}
382382
}
383383

@@ -746,7 +746,7 @@ void RegisterHTTPHandler(const std::string &prefix, bool exactMatch, const HTTPR
746746
{
747747
LogPrint(BCLog::HTTP, "Registering HTTP handler for %s (exactmatch %d)\n", prefix, exactMatch);
748748
LOCK(g_httppathhandlers_mutex);
749-
pathHandlers.push_back(HTTPPathHandler(prefix, exactMatch, handler));
749+
pathHandlers.emplace_back(prefix, exactMatch, handler);
750750
}
751751

752752
void UnregisterHTTPHandler(const std::string &prefix, bool exactMatch)

src/net_permissions.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ bool TryParsePermissionFlags(const std::string& str, NetPermissionFlags& output,
7171
std::vector<std::string> NetPermissions::ToStrings(NetPermissionFlags flags)
7272
{
7373
std::vector<std::string> strings;
74-
if (NetPermissions::HasFlag(flags, NetPermissionFlags::BloomFilter)) strings.push_back("bloomfilter");
75-
if (NetPermissions::HasFlag(flags, NetPermissionFlags::NoBan)) strings.push_back("noban");
76-
if (NetPermissions::HasFlag(flags, NetPermissionFlags::ForceRelay)) strings.push_back("forcerelay");
77-
if (NetPermissions::HasFlag(flags, NetPermissionFlags::Relay)) strings.push_back("relay");
78-
if (NetPermissions::HasFlag(flags, NetPermissionFlags::Mempool)) strings.push_back("mempool");
79-
if (NetPermissions::HasFlag(flags, NetPermissionFlags::Download)) strings.push_back("download");
80-
if (NetPermissions::HasFlag(flags, NetPermissionFlags::Addr)) strings.push_back("addr");
74+
if (NetPermissions::HasFlag(flags, NetPermissionFlags::BloomFilter)) strings.emplace_back("bloomfilter");
75+
if (NetPermissions::HasFlag(flags, NetPermissionFlags::NoBan)) strings.emplace_back("noban");
76+
if (NetPermissions::HasFlag(flags, NetPermissionFlags::ForceRelay)) strings.emplace_back("forcerelay");
77+
if (NetPermissions::HasFlag(flags, NetPermissionFlags::Relay)) strings.emplace_back("relay");
78+
if (NetPermissions::HasFlag(flags, NetPermissionFlags::Mempool)) strings.emplace_back("mempool");
79+
if (NetPermissions::HasFlag(flags, NetPermissionFlags::Download)) strings.emplace_back("download");
80+
if (NetPermissions::HasFlag(flags, NetPermissionFlags::Addr)) strings.emplace_back("addr");
8181
return strings;
8282
}
8383

src/net_processing.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -2359,7 +2359,7 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
23592359
// and we want it right after the last block so they don't
23602360
// wait for other stuff first.
23612361
std::vector<CInv> vInv;
2362-
vInv.push_back(CInv(MSG_BLOCK, m_chainman.ActiveChain().Tip()->GetBlockHash()));
2362+
vInv.emplace_back(MSG_BLOCK, m_chainman.ActiveChain().Tip()->GetBlockHash());
23632363
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::INV, vInv));
23642364
peer.m_continuation_block.SetNull();
23652365
}
@@ -2761,7 +2761,7 @@ void PeerManagerImpl::HeadersDirectFetchBlocks(CNode& pfrom, const Peer& peer, c
27612761
break;
27622762
}
27632763
uint32_t nFetchFlags = GetFetchFlags(peer);
2764-
vGetData.push_back(CInv(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash()));
2764+
vGetData.emplace_back(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash());
27652765
BlockRequested(pfrom.GetId(), *pindex);
27662766
LogPrint(BCLog::NET, "Requesting block %s from peer=%d\n",
27672767
pindex->GetBlockHash().ToString(), pfrom.GetId());
@@ -3299,7 +3299,7 @@ void PeerManagerImpl::ProcessCompactBlockTxns(CNode& pfrom, Peer& peer, const Bl
32993299
if (first_in_flight) {
33003300
// Might have collided, fall back to getdata now :(
33013301
std::vector<CInv> invs;
3302-
invs.push_back(CInv(MSG_BLOCK | GetFetchFlags(peer), block_transactions.blockhash));
3302+
invs.emplace_back(MSG_BLOCK | GetFetchFlags(peer), block_transactions.blockhash);
33033303
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::GETDATA, invs));
33043304
} else {
33053305
RemoveBlockRequest(block_transactions.blockhash, pfrom.GetId());
@@ -4149,7 +4149,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
41494149
LogPrint(BCLog::NET, "getheaders %d to %s from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.IsNull() ? "end" : hashStop.ToString(), pfrom.GetId());
41504150
for (; pindex; pindex = m_chainman.ActiveChain().Next(pindex))
41514151
{
4152-
vHeaders.push_back(pindex->GetBlockHeader());
4152+
vHeaders.emplace_back(pindex->GetBlockHeader());
41534153
if (--nLimit <= 0 || pindex->GetBlockHash() == hashStop)
41544154
break;
41554155
}
@@ -5649,14 +5649,14 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
56495649
pBestIndex = pindex;
56505650
if (fFoundStartingHeader) {
56515651
// add this to the headers message
5652-
vHeaders.push_back(pindex->GetBlockHeader());
5652+
vHeaders.emplace_back(pindex->GetBlockHeader());
56535653
} else if (PeerHasHeader(&state, pindex)) {
56545654
continue; // keep looking for the first new block
56555655
} else if (pindex->pprev == nullptr || PeerHasHeader(&state, pindex->pprev)) {
56565656
// Peer doesn't have this header but they do have the prior one.
56575657
// Start sending headers.
56585658
fFoundStartingHeader = true;
5659-
vHeaders.push_back(pindex->GetBlockHeader());
5659+
vHeaders.emplace_back(pindex->GetBlockHeader());
56605660
} else {
56615661
// Peer doesn't have this header or the prior one -- nothing will
56625662
// connect, so bail out.
@@ -5742,7 +5742,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
57425742

57435743
// Add blocks
57445744
for (const uint256& hash : peer->m_blocks_for_inv_relay) {
5745-
vInv.push_back(CInv(MSG_BLOCK, hash));
5745+
vInv.emplace_back(MSG_BLOCK, hash);
57465746
if (vInv.size() == MAX_INV_SZ) {
57475747
m_connman.PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv));
57485748
vInv.clear();
@@ -5948,7 +5948,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
59485948
}
59495949
for (const CBlockIndex *pindex : vToDownload) {
59505950
uint32_t nFetchFlags = GetFetchFlags(*peer);
5951-
vGetData.push_back(CInv(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash()));
5951+
vGetData.emplace_back(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash());
59525952
BlockRequested(pto->GetId(), *pindex);
59535953
LogPrint(BCLog::NET, "Requesting block %s (%d) peer=%d\n", pindex->GetBlockHash().ToString(),
59545954
pindex->nHeight, pto->GetId());

src/node/blockstorage.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ bool BlockManager::WriteBlockIndexDB()
458458
std::vector<std::pair<int, const CBlockFileInfo*>> vFiles;
459459
vFiles.reserve(m_dirty_fileinfo.size());
460460
for (std::set<int>::iterator it = m_dirty_fileinfo.begin(); it != m_dirty_fileinfo.end();) {
461-
vFiles.push_back(std::make_pair(*it, &m_blockfile_info[*it]));
461+
vFiles.emplace_back(*it, &m_blockfile_info[*it]);
462462
m_dirty_fileinfo.erase(it++);
463463
}
464464
std::vector<const CBlockIndex*> vBlocks;

src/node/interfaces.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ class ChainImpl : public Chain
674674
if (!m_node.mempool) {
675675
std::map<COutPoint, CAmount> bump_fees;
676676
for (const auto& outpoint : outpoints) {
677-
bump_fees.emplace(std::make_pair(outpoint, 0));
677+
bump_fees.emplace(outpoint, 0);
678678
}
679679
return bump_fees;
680680
}

src/psbt.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ struct PSBTOutput
874874
if ((leaf_ver & ~TAPROOT_LEAF_MASK) != 0) {
875875
throw std::ios_base::failure("Output Taproot tree has a leaf with an invalid leaf version");
876876
}
877-
m_tap_tree.push_back(std::make_tuple(depth, leaf_ver, script));
877+
m_tap_tree.emplace_back(depth, leaf_ver, script);
878878
builder.Add((int)depth, script, (int)leaf_ver, /*track=*/true);
879879
}
880880
if (!builder.IsComplete()) {

src/qt/rpcconsole.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class PeerIdViewDelegate : public QStyledItemDelegate
169169
bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strResult, const std::string &strCommand, const bool fExecute, std::string * const pstrFilteredOut, const WalletModel* wallet_model)
170170
{
171171
std::vector< std::vector<std::string> > stack;
172-
stack.push_back(std::vector<std::string>());
172+
stack.emplace_back();
173173

174174
enum CmdParseState
175175
{
@@ -197,7 +197,7 @@ bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strRes
197197
}
198198
// Make sure stack is not empty before adding something
199199
if (stack.empty()) {
200-
stack.push_back(std::vector<std::string>());
200+
stack.emplace_back();
201201
}
202202
stack.back().push_back(strArg);
203203
};
@@ -206,7 +206,7 @@ bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strRes
206206
if (nDepthInsideSensitive) {
207207
if (!--nDepthInsideSensitive) {
208208
assert(filter_begin_pos);
209-
filter_ranges.push_back(std::make_pair(filter_begin_pos, chpos));
209+
filter_ranges.emplace_back(filter_begin_pos, chpos);
210210
filter_begin_pos = 0;
211211
}
212212
}
@@ -306,7 +306,7 @@ bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strRes
306306
if (nDepthInsideSensitive) {
307307
++nDepthInsideSensitive;
308308
}
309-
stack.push_back(std::vector<std::string>());
309+
stack.emplace_back();
310310
}
311311

312312
// don't allow commands after executed commands on baselevel

src/rest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ static bool rest_getutxos(const std::any& context, HTTPRequest* req, const std::
798798
return RESTERR(req, HTTP_BAD_REQUEST, "Parse error");
799799

800800
txid.SetHex(strTxid);
801-
vOutPoints.push_back(COutPoint(txid, (uint32_t)nOutput));
801+
vOutPoints.emplace_back(txid, (uint32_t)nOutput);
802802
}
803803

804804
if (vOutPoints.size() > 0)

src/rpc/blockchain.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1930,7 +1930,7 @@ static RPCHelpMan getblockstats()
19301930
// New feerate uses satoshis per virtual byte instead of per serialized byte
19311931
CAmount feerate = weight ? (txfee * WITNESS_SCALE_FACTOR) / weight : 0;
19321932
if (do_feerate_percentiles) {
1933-
feerate_array.emplace_back(std::make_pair(feerate, weight));
1933+
feerate_array.emplace_back(feerate, weight);
19341934
}
19351935
maxfeerate = std::max(maxfeerate, feerate);
19361936
minfeerate = std::min(minfeerate, feerate);

src/rpc/rawtransaction.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1581,10 +1581,10 @@ static RPCHelpMan createpsbt()
15811581
PartiallySignedTransaction psbtx;
15821582
psbtx.tx = rawTx;
15831583
for (unsigned int i = 0; i < rawTx.vin.size(); ++i) {
1584-
psbtx.inputs.push_back(PSBTInput());
1584+
psbtx.inputs.emplace_back();
15851585
}
15861586
for (unsigned int i = 0; i < rawTx.vout.size(); ++i) {
1587-
psbtx.outputs.push_back(PSBTOutput());
1587+
psbtx.outputs.emplace_back();
15881588
}
15891589

15901590
// Serialize the PSBT
@@ -1648,10 +1648,10 @@ static RPCHelpMan converttopsbt()
16481648
PartiallySignedTransaction psbtx;
16491649
psbtx.tx = tx;
16501650
for (unsigned int i = 0; i < tx.vin.size(); ++i) {
1651-
psbtx.inputs.push_back(PSBTInput());
1651+
psbtx.inputs.emplace_back();
16521652
}
16531653
for (unsigned int i = 0; i < tx.vout.size(); ++i) {
1654-
psbtx.outputs.push_back(PSBTOutput());
1654+
psbtx.outputs.emplace_back();
16551655
}
16561656

16571657
// Serialize the PSBT

src/rpc/server.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ std::string CRPCTable::help(const std::string& strCommand, const JSONRPCRequest&
8888
vCommands.reserve(mapCommands.size());
8989

9090
for (const auto& entry : mapCommands)
91-
vCommands.push_back(make_pair(entry.second.front()->category + entry.first, entry.second.front()));
91+
vCommands.emplace_back(entry.second.front()->category + entry.first, entry.second.front());
9292
sort(vCommands.begin(), vCommands.end());
9393

9494
JSONRPCRequest jreq = helpreq;

src/script/sign.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ static bool SignStep(const SigningProvider& provider, const BaseSignatureCreator
433433
case TxoutType::SCRIPTHASH: {
434434
uint160 h160{vSolutions[0]};
435435
if (GetCScript(provider, sigdata, CScriptID{h160}, scriptRet)) {
436-
ret.push_back(std::vector<unsigned char>(scriptRet.begin(), scriptRet.end()));
436+
ret.emplace_back(scriptRet.begin(), scriptRet.end());
437437
return true;
438438
}
439439
// Could not find redeemScript, add to missing
@@ -442,7 +442,7 @@ static bool SignStep(const SigningProvider& provider, const BaseSignatureCreator
442442
}
443443
case TxoutType::MULTISIG: {
444444
size_t required = vSolutions.front()[0];
445-
ret.push_back(valtype()); // workaround CHECKMULTISIG bug
445+
ret.emplace_back(); // workaround CHECKMULTISIG bug
446446
for (size_t i = 1; i < vSolutions.size() - 1; ++i) {
447447
CPubKey pubkey = CPubKey(vSolutions[i]);
448448
// We need to always call CreateSig in order to fill sigdata with all
@@ -456,7 +456,7 @@ static bool SignStep(const SigningProvider& provider, const BaseSignatureCreator
456456
}
457457
bool ok = ret.size() == required + 1;
458458
for (size_t i = 0; i + ret.size() < required + 1; ++i) {
459-
ret.push_back(valtype());
459+
ret.emplace_back();
460460
}
461461
return ok;
462462
}
@@ -466,7 +466,7 @@ static bool SignStep(const SigningProvider& provider, const BaseSignatureCreator
466466

467467
case TxoutType::WITNESS_V0_SCRIPTHASH:
468468
if (GetCScript(provider, sigdata, CScriptID{RIPEMD160(vSolutions[0])}, scriptRet)) {
469-
ret.push_back(std::vector<unsigned char>(scriptRet.begin(), scriptRet.end()));
469+
ret.emplace_back(scriptRet.begin(), scriptRet.end());
470470
return true;
471471
}
472472
// Could not find witnessScript, add to missing
@@ -544,7 +544,7 @@ bool ProduceSignature(const SigningProvider& provider, const BaseSignatureCreato
544544
const auto ms = miniscript::FromScript(witnessscript, ms_satisfier);
545545
solved = ms && ms->Satisfy(ms_satisfier, result) == miniscript::Availability::YES;
546546
}
547-
result.push_back(std::vector<unsigned char>(witnessscript.begin(), witnessscript.end()));
547+
result.emplace_back(witnessscript.begin(), witnessscript.end());
548548

549549
sigdata.scriptWitness.stack = result;
550550
sigdata.witness = true;
@@ -561,7 +561,7 @@ bool ProduceSignature(const SigningProvider& provider, const BaseSignatureCreato
561561

562562
if (!sigdata.witness) sigdata.scriptWitness.stack.clear();
563563
if (P2SH) {
564-
result.push_back(std::vector<unsigned char>(subscript.begin(), subscript.end()));
564+
result.emplace_back(subscript.begin(), subscript.end());
565565
}
566566
sigdata.scriptSig = PushAll(result);
567567

0 commit comments

Comments
 (0)