reserve correctly when limit is numeric_limits::max() (#198)

This commit is contained in:
Nathan Nichols
2022-06-28 09:28:00 -07:00
committed by GitHub
parent 55f0536dca
commit 4e581e659f

View File

@@ -694,7 +694,10 @@ traverseOwnedNodes(
auto currentIndex = rootIndex;
std::vector<ripple::uint256> keys;
keys.reserve(limit);
// Only reserve 2048 nodes when fetching all owned ledger objects. If there
// are more, then keys will allocate more memory, which is suboptimal, but
// should only occur occasionally.
keys.reserve(std::min(std::uint32_t{2048}, limit));
auto start = std::chrono::system_clock::now();