From 5873561b5458ea58f13a805643ba5dba6f179d12 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 24 Oct 2019 22:33:48 +0200 Subject: [PATCH] Add cached thread retriever. --- server/TracyWorker.cpp | 15 +++++++++++++++ server/TracyWorker.hpp | 8 +++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 48ffbf0c..1c19b84c 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -2654,6 +2654,21 @@ ThreadData* Worker::NoticeThreadReal( uint64_t thread ) } } +ThreadData* Worker::RetrieveThreadReal( uint64_t thread ) +{ + auto it = m_threadMap.find( thread ); + if( it != m_threadMap.end() ) + { + m_data.threadDataLast.first = thread; + m_data.threadDataLast.second = it->second; + return it->second; + } + else + { + return nullptr; + } +} + const ThreadData* Worker::GetThreadData( uint64_t tid ) const { auto it = m_threadMap.find( tid ); diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index f0157aac..8a8acf9f 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -482,11 +482,17 @@ private: ThreadData* NoticeThreadReal( uint64_t thread ); ThreadData* NewThread( uint64_t thread ); - ThreadData* NoticeThread( uint64_t thread ) + tracy_force_inline ThreadData* NoticeThread( uint64_t thread ) { if( m_data.threadDataLast.first == thread ) return m_data.threadDataLast.second; return NoticeThreadReal( thread ); } + ThreadData* RetrieveThreadReal( uint64_t thread ); + tracy_force_inline ThreadData* RetrieveThread( uint64_t thread ) + { + if( m_data.threadDataLast.first == thread ) return m_data.threadDataLast.second; + return RetrieveThreadReal( thread ); + } tracy_force_inline void NewZone( ZoneEvent* zone, uint64_t thread );