summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjan.reininghaus <jan.reininghaus@8e3bb3c2-eed4-f18f-5264-0b6c94e6926d>2013-04-29 14:21:18 +0000
committerjan.reininghaus <jan.reininghaus@8e3bb3c2-eed4-f18f-5264-0b6c94e6926d>2013-04-29 14:21:18 +0000
commite8a7b44530bf449f2d895780ed5ca310c9c27206 (patch)
treea23cb638138b026cd107509a103c85da0f8050e7
parent89afd70e622d03bca4e4189ada72d602b7070992 (diff)
improved vector_vector.h performance
git-svn-id: https://phat.googlecode.com/svn/trunk@47 8e3bb3c2-eed4-f18f-5264-0b6c94e6926d
-rw-r--r--include/phat/representations/vector_vector.h12
1 files 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 );
}
};
}