From e8a7b44530bf449f2d895780ed5ca310c9c27206 Mon Sep 17 00:00:00 2001 From: "jan.reininghaus" Date: Mon, 29 Apr 2013 14:21:18 +0000 Subject: improved vector_vector.h performance git-svn-id: https://phat.googlecode.com/svn/trunk@47 8e3bb3c2-eed4-f18f-5264-0b6c94e6926d --- include/phat/representations/vector_vector.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/include/phat/representations/vector_vector.h b/include/phat/representations/vector_vector.h index bdef522..84609c2 100644 --- a/include/phat/representations/vector_vector.h +++ b/include/phat/representations/vector_vector.h @@ -27,6 +27,8 @@ namespace phat { std::vector< dimension > dims; std::vector< column > matrix; + thread_local_storage< column > temp_column_buffer; + public: // overall number of cells in boundary_matrix index _get_num_cols() const { @@ -80,12 +82,12 @@ namespace phat { void _add_to( index source, index target ) { column& source_col = matrix[ source ]; column& target_col = matrix[ target ]; - column temp_col; - target_col.swap( temp_col ); - target_col.reserve( temp_col.size() ); - std::set_symmetric_difference( temp_col.begin(), temp_col.end(), + column& temp_col = temp_column_buffer(); + temp_col.clear(); + std::set_symmetric_difference( target_col.begin(), target_col.end(), source_col.begin(), source_col.end(), - std::back_inserter( target_col ) ); + std::back_inserter( temp_col ) ); + target_col.swap( temp_col ); } }; } -- cgit v1.2.3