Manual ZoneEvent vector initialization.

This commit is contained in:
Bartosz Taudul 2017-11-15 22:13:23 +01:00
parent 13d8d9255e
commit afa9eec5dd
3 changed files with 11 additions and 3 deletions

View File

@ -66,6 +66,8 @@ enum { SourceLocationSize = sizeof( SourceLocation ) };
struct ZoneEvent
{
void Init() { memset( &child, 0, 12 ); }
int64_t start;
int64_t end;
int32_t srcloc;
@ -77,6 +79,7 @@ struct ZoneEvent
};
enum { ZoneEventSize = sizeof( ZoneEvent ) };
static_assert( sizeof( ZoneEvent::child ) == 13, "Adjust vector clear size!" );
struct LockEvent

View File

@ -174,6 +174,7 @@ private:
{
memUsage.fetch_add( sizeof( T ), std::memory_order_relaxed );
m_ptr = new T[1];
m_capacity = 0;
}
else
{

View File

@ -615,7 +615,8 @@ void View::Process( const QueueItem& ev )
void View::ProcessZoneBegin( const QueueZoneBegin& ev )
{
auto zone = m_slab.AllocInit<ZoneEvent>();
auto zone = m_slab.Alloc<ZoneEvent>();
zone->Init();
CheckSourceLocation( ev.srcloc );
@ -636,7 +637,8 @@ void View::ProcessZoneBeginAllocSrcLoc( const QueueZoneBegin& ev )
auto it = m_pendingSourceLocationPayload.find( ev.srcloc );
assert( it != m_pendingSourceLocationPayload.end() );
auto zone = m_slab.AllocInit<ZoneEvent>();
auto zone = m_slab.Alloc<ZoneEvent>();
zone->Init();
zone->start = ev.time * m_timerMul;
zone->end = -1;
@ -3845,7 +3847,9 @@ void View::ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec )
for( uint64_t i=0; i<sz; i++ )
{
auto zone = m_slab.AllocInit<ZoneEvent>();
auto zone = m_slab.Alloc<ZoneEvent>();
zone->Init();
m_zonesCnt++;
vec.push_back( zone );