From e90ddf7ee549cfc5aeac3ead20088faef0a8d03a Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 15 Aug 2019 23:01:25 +0200 Subject: [PATCH] Don't search whole data set twice. --- server/TracyView.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 99603e2a..dab0028a 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -4852,12 +4852,11 @@ void View::DrawZoneInfoWindow() { const auto thread = m_worker.CompressThread( tid ); - // TODO: use ait, fit as begin for aend, fend search auto ait = std::lower_bound( mem.data.begin(), mem.data.end(), ev.Start(), [] ( const auto& l, const auto& r ) { return l.TimeAlloc() < r; } ); - const auto aend = std::upper_bound( mem.data.begin(), mem.data.end(), end, [] ( const auto& l, const auto& r ) { return l < r.TimeAlloc(); } ); + const auto aend = std::upper_bound( ait, mem.data.end(), end, [] ( const auto& l, const auto& r ) { return l < r.TimeAlloc(); } ); auto fit = std::lower_bound( mem.frees.begin(), mem.frees.end(), ev.Start(), [&mem] ( const auto& l, const auto& r ) { return mem.data[l].TimeFree() < r; } ); - const auto fend = std::upper_bound( mem.frees.begin(), mem.frees.end(), end, [&mem] ( const auto& l, const auto& r ) { return l < mem.data[r].TimeFree(); } ); + const auto fend = std::upper_bound( fit, mem.frees.end(), end, [&mem] ( const auto& l, const auto& r ) { return l < mem.data[r].TimeFree(); } ); const auto aDist = std::distance( ait, aend ); const auto fDist = std::distance( fit, fend );