diff options
author | Ava Chow <github@achow101.com> | 2024-10-16 09:20:23 -0400 |
---|---|---|
committer | Ava Chow <github@achow101.com> | 2024-10-16 09:20:23 -0400 |
commit | dea9fb9a8b8fe9426be465f61d9e4540e888c2fc (patch) | |
tree | b8f2f8ce8f7294645ff6703fef6fbb672f3be264 | |
parent | 2123c94448ed142e78942421c597a1f264859c48 (diff) | |
parent | ec585f11c38bbe277a596dcea3c813e7c6626050 (diff) |
Merge bitcoin/bitcoin#30093: optimization: reserve memory allocation for transaction inputs/outputs
ec585f11c38bbe277a596dcea3c813e7c6626050 Reserve space for transaction inputs in CreateTransactionInternal (Lőrinc)
c76aaaf90034a15917d02a71e3fdc36e8dd927f6 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 ec585f11c38bbe277a596dcea3c813e7c6626050
TheCharlatan:
ACK ec585f11c38bbe277a596dcea3c813e7c6626050
stickies-v:
ACK ec585f11c38bbe277a596dcea3c813e7c6626050
Tree-SHA512: de399fb19824423467f48af64aa57f41a23cdd00eb17461e0131e4deafdd15e0d2daebf6a0a7ac7728b2fb486b2a54f1a7ef26bbe823c56b2a09f892f6b9a581
-rw-r--r-- | src/wallet/spend.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index 7abf7f59c0..aceed24a86 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -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)); @@ -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) { |