[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master b7d99ed 1/5: Reserve memory all at once befor
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master b7d99ed 1/5: Reserve memory all at once before appending to cell_parms() |
Date: |
Tue, 13 Feb 2018 08:02:39 -0500 (EST) |
branch: master
commit b7d99ede16c6d844d8f85279ae364a6366faa7a6
Author: Vadim Zeitlin <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Reserve memory all at once before appending to cell_parms()
This trivial optimization reduces the number of memory allocations,
helping with both the run-time and memory consumption, when copying the
new cells to cell_parms() after pasting data into a census.
---
census_view.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/census_view.cpp b/census_view.cpp
index ea21aa5..1a9cda7 100644
--- a/census_view.cpp
+++ b/census_view.cpp
@@ -1773,6 +1773,7 @@ void CensusView::UponPasteCensus(wxCommandEvent&)
}
auto selection = cell_parms().size();
+ cell_parms().reserve(cell_parms().size() + cells.size());
std::back_insert_iterator<std::vector<Input>> iip(cell_parms());
std::copy(cells.begin(), cells.end(), iip);
document().Modify(true);