Skip to content

Commit dea9fb9

Browse files
committed
Merge bitcoin#30093: optimization: reserve memory allocation for transaction inputs/outputs
ec585f1 Reserve space for transaction inputs in CreateTransactionInternal (Lőrinc) c76aaaf Reserve space for transaction outputs in CreateTransactionInternal (Lőrinc) Pull request description: Reserved memory for the transaction inputs and outputs. Split out of https://github.com/bitcoin/bitcoin/pull/30050/files#r1597631104 ACKs for top commit: achow101: ACK ec585f1 TheCharlatan: ACK ec585f1 stickies-v: ACK ec585f1 Tree-SHA512: de399fb19824423467f48af64aa57f41a23cdd00eb17461e0131e4deafdd15e0d2daebf6a0a7ac7728b2fb486b2a54f1a7ef26bbe823c56b2a09f892f6b9a581
2 parents 2123c94 + ec585f1 commit dea9fb9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/wallet/spend.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
11671167
result.GetSelectedValue());
11681168

11691169
// vouts to the payees
1170+
txNew.vout.reserve(vecSend.size() + 1); // + 1 because of possible later insert
11701171
for (const auto& recipient : vecSend)
11711172
{
11721173
txNew.vout.emplace_back(recipient.nAmount, GetScriptForDestination(recipient.dest));
@@ -1217,6 +1218,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
12171218
// behavior."
12181219
bool use_anti_fee_sniping = true;
12191220
const uint32_t default_sequence{coin_control.m_signal_bip125_rbf.value_or(wallet.m_signal_rbf) ? MAX_BIP125_RBF_SEQUENCE : CTxIn::MAX_SEQUENCE_NONFINAL};
1221+
txNew.vin.reserve(selected_coins.size());
12201222
for (const auto& coin : selected_coins) {
12211223
std::optional<uint32_t> sequence = coin_control.GetSequence(coin->outpoint);
12221224
if (sequence) {

0 commit comments

Comments
 (0)