From 5278bb29e654af9c1ec1acd735f75be95827f70c Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 19 Oct 2017 19:43:27 +0200 Subject: [PATCH] Don't sort all values in a compressed range. --- server/TracyView.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index c799dad5..9ac7594a 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -2495,18 +2495,28 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover ) { prevx = it; - if( m_tmpVecSize < rsz ) + const auto skip = std::max( 1, rsz / 1024 ); + const auto sz = rsz / skip + 1; + + if( m_tmpVecSize < sz ) { delete[] m_tmpVec; - m_tmpVec = new double[rsz]; - m_tmpVecSize = rsz; + m_tmpVec = new double[sz]; + m_tmpVecSize = sz; } auto dst = m_tmpVec; - while( it < range ) + for(;;) { *dst++ = it->val; - ++it; + if( std::distance( it, range ) > skip ) + { + it += skip; + } + else + { + break; + } } std::sort( m_tmpVec, dst, [] ( const auto& l, const auto& r ) { return l < r; } );