From 75e3dd175a3190893fdd625d4ec60664b57469f8 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 21 Oct 2017 13:14:20 +0200 Subject: [PATCH] One function for adding threads. --- server/TracyView.cpp | 42 ++++++++++-------------------------------- server/TracyView.hpp | 2 ++ 2 files changed, 12 insertions(+), 32 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 50e26d91..a7c86335 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -880,23 +880,7 @@ void View::InsertMessageData( MessageData* msg, uint64_t thread ) m_messages.insert( mit, msg ); } - Vector* vec; - auto tit = m_threadMap.find( thread ); - if( tit == m_threadMap.end() ) - { - CheckThreadString( thread ); - m_threadMap.emplace( thread, (uint32_t)m_threads.size() ); - auto td = m_slab.AllocInit(); - td->id = thread; - td->enabled = true; - m_threads.push_back( td ); - vec = &m_threads.back()->messages; - } - else - { - vec = &m_threads[tit->second]->messages; - } - + Vector* vec = &NoticeThread( thread )->messages; if( vec->empty() || vec->back()->time < msg->time ) { vec->push_back( msg ); @@ -908,10 +892,8 @@ void View::InsertMessageData( MessageData* msg, uint64_t thread ) } } -void View::NewZone( Event* zone, uint64_t thread ) +View::ThreadData* View::NoticeThread( uint64_t thread ) { - m_zonesCnt++; - Vector* timeline; auto it = m_threadMap.find( thread ); if( it == m_threadMap.end() ) { @@ -921,13 +903,18 @@ void View::NewZone( Event* zone, uint64_t thread ) td->id = thread; td->enabled = true; m_threads.push_back( td ); - timeline = &m_threads.back()->timeline; + return m_threads.back(); } else { - timeline = &m_threads[it->second]->timeline; + return m_threads[it->second]; } +} +void View::NewZone( Event* zone, uint64_t thread ) +{ + m_zonesCnt++; + Vector* timeline = &NoticeThread( thread )->timeline; InsertZone( zone, nullptr, *timeline ); } @@ -963,16 +950,7 @@ void View::InsertZone( Event* zone, Event* parent, Vector& vec ) void View::InsertLockEvent( LockMap& lockmap, LockEvent* lev, uint64_t thread ) { - auto tit = m_threadMap.find( thread ); - if( tit == m_threadMap.end() ) - { - CheckThreadString( thread ); - m_threadMap.emplace( thread, (uint32_t)m_threads.size() ); - auto td = m_slab.AllocInit(); - td->id = thread; - td->enabled = true; - m_threads.push_back( td ); - } + NoticeThread( thread ); auto it = lockmap.threadMap.find( thread ); if( it == lockmap.threadMap.end() ) diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 6d0992bd..97b41002 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -137,6 +137,8 @@ private: void InsertMessageData( MessageData* msg, uint64_t thread ); + ThreadData* NoticeThread( uint64_t thread ); + void NewZone( Event* zone, uint64_t thread ); void UpdateZone( Event* zone );