summaryrefslogtreecommitdiff
path: root/src/python/include/Persistent_cohomology_interface.h
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2020-03-23 18:52:49 +0100
committerMarc Glisse <marc.glisse@inria.fr>2020-03-23 18:52:49 +0100
commit527d57993af98b030e67bf601703e08dd42fd20b (patch)
treee7cce5591b1f51c12d373c357411f04ba921a58e /src/python/include/Persistent_cohomology_interface.h
parent0b4eddeb0d53d465016d5eb913b382123bc5b891 (diff)
Reuse vector
Reuse + copy should be slightly faster than regrowing each time (and moving)
Diffstat (limited to 'src/python/include/Persistent_cohomology_interface.h')
-rw-r--r--src/python/include/Persistent_cohomology_interface.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/python/include/Persistent_cohomology_interface.h b/src/python/include/Persistent_cohomology_interface.h
index 89ff5137..3ce40af5 100644
--- a/src/python/include/Persistent_cohomology_interface.h
+++ b/src/python/include/Persistent_cohomology_interface.h
@@ -73,15 +73,17 @@ persistent_cohomology::Persistent_cohomology<FilteredComplex, persistent_cohomol
std::vector<std::pair<std::vector<int>, std::vector<int>>> persistence_pairs;
auto const& pairs = Base::get_persistent_pairs();
persistence_pairs.reserve(pairs.size());
+ std::vector<int> birth;
+ std::vector<int> death;
for (auto pair : pairs) {
- std::vector<int> birth;
+ birth.clear();
if (get<0>(pair) != stptr_->null_simplex()) {
for (auto vertex : stptr_->simplex_vertex_range(get<0>(pair))) {
birth.push_back(vertex);
}
}
- std::vector<int> death;
+ death.clear();
if (get<1>(pair) != stptr_->null_simplex()) {
death.reserve(birth.size()+1);
for (auto vertex : stptr_->simplex_vertex_range(get<1>(pair))) {
@@ -89,7 +91,7 @@ persistent_cohomology::Persistent_cohomology<FilteredComplex, persistent_cohomol
}
}
- persistence_pairs.emplace_back(std::move(birth), std::move(death));
+ persistence_pairs.emplace_back(birth, death);
}
return persistence_pairs;
}