Skip to content

Commit

Permalink
Merge bitcoin/bitcoin#30093: optimization: reserve memory allocation …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
achow101 committed Oct 16, 2024
2 parents 2123c94 + ec585f1 commit dea9fb9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/wallet/spend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
result.GetSelectedValue());

// vouts to the payees
txNew.vout.reserve(vecSend.size() + 1); // + 1 because of possible later insert
for (const auto& recipient : vecSend)
{
txNew.vout.emplace_back(recipient.nAmount, GetScriptForDestination(recipient.dest));
Expand Down Expand Up @@ -1217,6 +1218,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
// behavior."
bool use_anti_fee_sniping = true;
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};
txNew.vin.reserve(selected_coins.size());
for (const auto& coin : selected_coins) {
std::optional<uint32_t> sequence = coin_control.GetSequence(coin->outpoint);
if (sequence) {
Expand Down

0 comments on commit dea9fb9

Please sign in to comment.