1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-30 12:53:51 +00:00

Wrapper for allocation and retrieval of zone extra.

This commit is contained in:
Bartosz Taudul 2020-02-20 23:37:55 +01:00
parent 217c16de20
commit 4bf0af321f
2 changed files with 11 additions and 8 deletions

View File

@ -3822,8 +3822,7 @@ void Worker::ProcessZoneText( const QueueZoneText& ev )
auto zone = stack.back(); auto zone = stack.back();
auto it = m_pendingCustomStrings.find( ev.text ); auto it = m_pendingCustomStrings.find( ev.text );
assert( it != m_pendingCustomStrings.end() ); assert( it != m_pendingCustomStrings.end() );
if( !HasZoneExtra( *zone ) ) AllocZoneExtra( *zone ); auto& extra = RequestZoneExtra( *zone );
auto& extra = GetZoneExtraMutable( *zone );
if( !extra.text.Active() ) if( !extra.text.Active() )
{ {
extra.text = StringIdx( it->second.idx ); extra.text = StringIdx( it->second.idx );
@ -3857,8 +3856,7 @@ void Worker::ProcessZoneName( const QueueZoneText& ev )
auto zone = stack.back(); auto zone = stack.back();
auto it = m_pendingCustomStrings.find( ev.text ); auto it = m_pendingCustomStrings.find( ev.text );
assert( it != m_pendingCustomStrings.end() ); assert( it != m_pendingCustomStrings.end() );
if( !HasZoneExtra( *zone ) ) AllocZoneExtra( *zone ); auto& extra = RequestZoneExtra( *zone );
auto& extra = GetZoneExtraMutable( *zone );
extra.name = StringIdx( it->second.idx ); extra.name = StringIdx( it->second.idx );
m_pendingCustomStrings.erase( it ); m_pendingCustomStrings.erase( it );
} }
@ -4513,8 +4511,7 @@ void Worker::ProcessCallstack( const QueueCallstack& ev )
{ {
case NextCallstackType::Zone: case NextCallstackType::Zone:
{ {
if( !HasZoneExtra( *next.zone ) ) AllocZoneExtra( *next.zone ); auto& extra = RequestZoneExtra( *next.zone );
auto& extra = GetZoneExtraMutable( *next.zone );
extra.callstack.SetVal( m_pendingCallstackId ); extra.callstack.SetVal( m_pendingCallstackId );
break; break;
} }
@ -4551,8 +4548,7 @@ void Worker::ProcessCallstackAlloc( const QueueCallstackAlloc& ev )
{ {
case NextCallstackType::Zone: case NextCallstackType::Zone:
{ {
if( !HasZoneExtra( *next.zone ) ) AllocZoneExtra( *next.zone ); auto& extra = RequestZoneExtra( *next.zone );
auto& extra = GetZoneExtraMutable( *next.zone );
extra.callstack.SetVal( m_pendingCallstackId ); extra.callstack.SetVal( m_pendingCallstackId );
break; break;
} }
@ -5991,4 +5987,10 @@ void Worker::AllocZoneExtra( ZoneEvent& ev )
memset( &extra, 0, sizeof( extra ) ); memset( &extra, 0, sizeof( extra ) );
} }
ZoneExtra& Worker::RequestZoneExtra( ZoneEvent& ev )
{
if( !HasZoneExtra( ev ) ) AllocZoneExtra( ev );
return GetZoneExtraMutable( ev );
}
} }

View File

@ -631,6 +631,7 @@ private:
tracy_force_inline ZoneExtra& GetZoneExtraMutable( const ZoneEvent& ev ) { return m_data.zoneExtra[ev.extra]; } tracy_force_inline ZoneExtra& GetZoneExtraMutable( const ZoneEvent& ev ) { return m_data.zoneExtra[ev.extra]; }
tracy_force_inline void AllocZoneExtra( ZoneEvent& ev ); tracy_force_inline void AllocZoneExtra( ZoneEvent& ev );
tracy_force_inline ZoneExtra& RequestZoneExtra( ZoneEvent& ev );
int64_t ReadTimeline( FileRead& f, Vector<short_ptr<ZoneEvent>>& vec, uint32_t size, int64_t refTime, int32_t& childIdx ); int64_t ReadTimeline( FileRead& f, Vector<short_ptr<ZoneEvent>>& vec, uint32_t size, int64_t refTime, int32_t& childIdx );
void ReadTimelinePre063( FileRead& f, Vector<short_ptr<ZoneEvent>>& vec, uint64_t size, int64_t& refTime, int32_t& childIdx, int fileVer ); void ReadTimelinePre063( FileRead& f, Vector<short_ptr<ZoneEvent>>& vec, uint64_t size, int64_t& refTime, int32_t& childIdx, int fileVer );