[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 38286b6 2/2: Avoid vector reallocations in ve
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 38286b6 2/2: Avoid vector reallocations in vector form of ledger_format() |
Date: |
Thu, 29 Jun 2017 18:25:16 -0400 (EDT) |
branch: master
commit 38286b6f829b37ee9044010bf927a2aaa203e3ae
Author: Vadim Zeitlin <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Avoid vector reallocations in vector form of ledger_format()
Pre-allocate all the space we need in advance, as it doesn't cost us
anything to do it here because we know the result vector size from the
beginning.
---
ledger_text_formats.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/ledger_text_formats.cpp b/ledger_text_formats.cpp
index 98db9a0..ccf5f50 100644
--- a/ledger_text_formats.cpp
+++ b/ledger_text_formats.cpp
@@ -1208,6 +1208,7 @@ std::vector<std::string> ledger_format
)
{
std::vector<std::string> sv;
+ sv.reserve(dv.size());
for(auto const& i : dv)
{
sv.push_back(ledger_format(i, f));