Return zone extra during allocation.

This commit is contained in:
Bartosz Taudul 2020-02-20 23:39:40 +01:00
parent 4bf0af321f
commit ecc9369da2
2 changed files with 12 additions and 6 deletions

View File

@ -5287,8 +5287,7 @@ void Worker::ReadTimelinePre063( FileRead& f, Vector<short_ptr<ZoneEvent>>& _vec
zone->extra = 0;
if( extra.callstack.Val() != 0 || extra.name.Active() || extra.text.Active() )
{
AllocZoneExtra( *zone );
memcpy( &GetZoneExtraMutable( *zone ), &extra, sizeof( ZoneExtra ) );
memcpy( &AllocZoneExtra( *zone ), &extra, sizeof( ZoneExtra ) );
}
refTime += zone->_end_child1;
zone->SetStart( refTime - m_data.baseTime );
@ -5979,18 +5978,25 @@ const Worker::CpuThreadTopology* Worker::GetThreadTopology( uint32_t cpuThread )
return &it->second;
}
void Worker::AllocZoneExtra( ZoneEvent& ev )
ZoneExtra& Worker::AllocZoneExtra( ZoneEvent& ev )
{
assert( ev.extra == 0 );
ev.extra = uint32_t( m_data.zoneExtra.size() );
auto& extra = m_data.zoneExtra.push_next();
memset( &extra, 0, sizeof( extra ) );
return extra;
}
ZoneExtra& Worker::RequestZoneExtra( ZoneEvent& ev )
{
if( !HasZoneExtra( ev ) ) AllocZoneExtra( ev );
return GetZoneExtraMutable( ev );
if( !HasZoneExtra( ev ) )
{
return AllocZoneExtra( ev );
}
else
{
return GetZoneExtraMutable( ev );
}
}
}

View File

@ -630,7 +630,7 @@ private:
#endif
tracy_force_inline ZoneExtra& GetZoneExtraMutable( const ZoneEvent& ev ) { return m_data.zoneExtra[ev.extra]; }
tracy_force_inline void AllocZoneExtra( ZoneEvent& ev );
tracy_force_inline ZoneExtra& 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 );