From ec58aa4ce1bda2e69c94b393ce9b36ec26aeb59c Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 30 Apr 2018 13:57:12 +0200 Subject: [PATCH] Don't increase vector size in each iteration. --- server/TracyWorker.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 9c7a07e7..a33f528e 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -1917,15 +1917,19 @@ void Worker::ReconstructMemAllocPlot() }; Vector frees; - frees.reserve( m_data.memory.data.size() ); - for( auto& v : m_data.memory.data ) { - if( v.timeFree >= 0 ) + frees.reserve( m_data.memory.data.size() ); + auto ptr = frees.data(); + for( auto& v : m_data.memory.data ) { - auto& f = frees.push_next_no_space_check(); - f.time = v.timeFree; - f.size = double( int64_t( v.size ) ); + if( v.timeFree >= 0 ) + { + ptr->time = v.timeFree; + ptr->size = double( int64_t( v.size ) ); + ptr++; + } } + frees.set_size( ptr - frees.data() ); } pdqsort_branchless( frees.begin(), frees.end(), [] ( const auto& lhs, const auto& rhs ) { return lhs.time < rhs.time; } );