From 527d57993af98b030e67bf601703e08dd42fd20b Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 23 Mar 2020 18:52:49 +0100 Subject: Reuse vector Reuse + copy should be slightly faster than regrowing each time (and moving) --- src/python/include/Persistent_cohomology_interface.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/python/include/Persistent_cohomology_interface.h') 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, std::vector>> persistence_pairs; auto const& pairs = Base::get_persistent_pairs(); persistence_pairs.reserve(pairs.size()); + std::vector birth; + std::vector death; for (auto pair : pairs) { - std::vector 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 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