From 9b5cc3352a46091c05a5663454126627e9560d9d Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 7 Feb 2021 20:26:58 +0100 Subject: [PATCH] Fast search for zone tid in GetZoneThreadData(). --- server/TracyView.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 0d0fe801..16a364ae 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -17312,6 +17312,21 @@ const GpuEvent* View::GetZoneParent( const GpuEvent& zone ) const const ThreadData* View::GetZoneThreadData( const ZoneEvent& zone ) const { +#ifndef TRACY_NO_STATISTICS + if( m_worker.AreSourceLocationZonesReady() ) + { + auto& slz = m_worker.GetZonesForSourceLocation( zone.SrcLoc() ); + if( !slz.zones.empty() ) + { + auto it = std::lower_bound( slz.zones.begin(), slz.zones.end(), zone.Start(), [] ( const auto& lhs, const auto& rhs ) { return lhs.Zone()->Start() < rhs; } ); + if( it != slz.zones.end() && it->Zone() == &zone ) + { + return m_worker.GetThreadData( m_worker.DecompressThread( it->Thread() ) ); + } + } + } +#endif + for( const auto& thread : m_worker.GetThreadData() ) { const Vector>* timeline = &thread->timeline;