Don't increase vector size in each iteration.

This commit is contained in:
Bartosz Taudul 2018-04-30 13:57:12 +02:00
parent e41ce5523c
commit ec58aa4ce1

View File

@ -1917,15 +1917,19 @@ void Worker::ReconstructMemAllocPlot()
}; };
Vector<FreeData> frees; Vector<FreeData> 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(); if( v.timeFree >= 0 )
f.time = v.timeFree; {
f.size = double( int64_t( v.size ) ); 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; } ); pdqsort_branchless( frees.begin(), frees.end(), [] ( const auto& lhs, const auto& rhs ) { return lhs.time < rhs.time; } );