wallet: correctly reserve in CoinsResult::All()
What changed, and why it matters
This is a tiny performance fix in the Bitcoin Core wallet code. A helper function that gathers all spendable coins into one flat list was reserving memory based on the number of coin categories (for example, how many output types exist) rather than the actual total number of coins. The change makes it reserve the correct, larger amount of memory up front. It does not change any security logic, balances, or transaction construction rules.
No security action required. Treat as a normal code-quality/performance improvement.
Security signals we found
No security-sensitive logic changed
No input validation, cryptography, consensus, or networking code modified
Memory reservation miscalculation could theoretically affect performance but not correctness or safety
No crash, overflow, or out-of-bounds access introduced or fixed
Evidence from the diff
CoinsResult::All() in src/wallet/spend.cpp flattens a std::map
Changed components
src/wallet/spend.cppCoinsResult::All()Inspect captured patch +1 / −1
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp
index a2ac727d..30edd62a 100644
--- a/src/wallet/spend.cpp
+++ b/src/wallet/spend.cpp
@@ -203,7 +203,7 @@ size_t CoinsResult::Size() const
std::vector<COutput> CoinsResult::All() const
{
std::vector<COutput> all;
- all.reserve(coins.size());
+ all.reserve(Size());
for (const auto& it : coins) {
all.insert(all.end(), it.second.begin(), it.second.end());
}
Why this scored 16/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.