From 61d775ecc8be85bc59ec8d9bc22c4a51131c156e Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 19 May 2019 16:26:59 +0200 Subject: [PATCH] Calculate end point before loop. --- server/TracyView.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index b044ff39..f6690e38 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -9388,9 +9388,10 @@ std::vector View::GetMemoryPages() const if( m_memInfo.restrictTime ) { const auto zvMid = m_zvStart + ( m_zvEnd - m_zvStart ) / 2; - for( auto& alloc : mem.data ) + auto end = std::upper_bound( mem.data.begin(), mem.data.end(), zvMid, []( const auto& lhs, const auto& rhs ) { return lhs < rhs.timeAlloc; } ); + for( auto it = mem.data.begin(); it != end; ++it ) { - if( alloc.timeAlloc > zvMid ) break; + auto& alloc = *it; const auto a0 = alloc.ptr - memlow; const auto a1 = a0 + alloc.size;