From 33f9c0525832f7bbd18f88fe5d174bea57e5a963 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 22 Jan 2014 22:14:09 +0100 Subject: [PATCH] added small optimization in range_collect_vectors - erase() replaced by copy from back and pop_back() --- .../geometry/algorithms/detail/equals/collect_vectors.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/boost/geometry/algorithms/detail/equals/collect_vectors.hpp b/include/boost/geometry/algorithms/detail/equals/collect_vectors.hpp index a4c63b25b..c81a8e13d 100644 --- a/include/boost/geometry/algorithms/detail/equals/collect_vectors.hpp +++ b/include/boost/geometry/algorithms/detail/equals/collect_vectors.hpp @@ -161,7 +161,12 @@ struct range_collect_vectors c_iterator first = collection.begin() + c_old_size; if ( first->same_direction(collection.back()) ) - collection.erase(first); + { + //collection.erase(first); + // O(1) instead of O(N) + *first = collection.back(); + collection.pop_back(); + } } } };