From 43c3fe25ba0bf4d5be296a0b1e7ef7a73c6950d4 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 18 Mar 2018 20:08:57 +0100 Subject: [PATCH] Put source location zone data into a struct. --- server/TracyWorker.cpp | 14 +++++++------- server/TracyWorker.hpp | 9 ++++++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 761b4586..369742c4 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -124,11 +124,11 @@ Worker::Worker( FileRead& f ) m_data.sourceLocationZones.reserve( sle + sz ); for( uint64_t i=1; i() ); + m_data.sourceLocationZones.emplace( int32_t( i ), SourceLocationZones() ); } for( uint64_t i=0; i() ); + m_data.sourceLocationZones.emplace( -int32_t( i + 1 ), SourceLocationZones() ); } #endif @@ -422,7 +422,7 @@ const Vector& Worker::GetZonesForSourceLocation( int32_t srcloc ) co { static const Vector empty; auto it = m_data.sourceLocationZones.find( srcloc ); - return it != m_data.sourceLocationZones.end() ? it->second : empty; + return it != m_data.sourceLocationZones.end() ? it->second.zones : empty; } #endif @@ -632,7 +632,7 @@ uint32_t Worker::NewShrinkedSourceLocation( uint64_t srcloc ) const auto sz = m_data.sourceLocationExpand.size(); m_data.sourceLocationExpand.push_back( srcloc ); #ifndef TRACY_NO_STATISTICS - m_data.sourceLocationZones.emplace( sz, Vector() ); + m_data.sourceLocationZones.emplace( sz, SourceLocationZones() ); #endif m_sourceLocationShrink.emplace( srcloc, sz ); return sz; @@ -701,7 +701,7 @@ void Worker::NewZone( ZoneEvent* zone, uint64_t thread ) #ifndef TRACY_NO_STATISTICS auto it = m_data.sourceLocationZones.find( zone->srcloc ); assert( it != m_data.sourceLocationZones.end() ); - it->second.push_back( zone ); + it->second.zones.push_back( zone ); #endif auto td = NoticeThread( thread ); @@ -969,7 +969,7 @@ void Worker::AddSourceLocationPayload( uint64_t ptr, char* data, size_t sz ) m_pendingSourceLocationPayload.emplace( ptr, -int32_t( idx + 1 ) ); m_data.sourceLocationPayload.push_back( slptr ); #ifndef TRACY_NO_STATISTICS - m_data.sourceLocationZones.emplace( -int32_t( idx + 1 ), Vector() ); + m_data.sourceLocationZones.emplace( -int32_t( idx + 1 ), SourceLocationZones() ); #endif } else @@ -1626,7 +1626,7 @@ void Worker::ReadTimeline( FileRead& f, Vector& vec, uint64_t size ) #ifndef TRACY_NO_STATISTICS auto it = m_data.sourceLocationZones.find( zone->srcloc ); assert( it != m_data.sourceLocationZones.end() ); - it->second.push_back( zone ); + it->second.zones.push_back( zone ); #endif ReadTimeline( f, zone->child ); diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index a5c517a2..57623c76 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -32,6 +32,13 @@ struct nohash class Worker { + struct SourceLocationZones + { + SourceLocationZones() {} + + Vector zones; + }; + struct DataBlock { DataBlock() : zonesCnt( 0 ), lastTime( 0 ) {} @@ -55,7 +62,7 @@ class Worker flat_hash_map sourceLocationPayloadMap; Vector sourceLocationExpand; #ifndef TRACY_NO_STATISTICS - flat_hash_map, nohash> sourceLocationZones; + flat_hash_map> sourceLocationZones; #endif std::map lockMap;