Allow direct access to data size table index.

This commit is contained in:
Bartosz Taudul 2017-09-14 01:05:08 +02:00
parent 89dd244693
commit 10b88754d8
3 changed files with 8 additions and 4 deletions

View File

@ -114,7 +114,7 @@ void Profiler::Worker()
char* ptr = buf; char* ptr = buf;
for( int i=0; i<sz; i++ ) for( int i=0; i<sz; i++ )
{ {
const auto dsz = QueueDataSize[(uint8_t)item[i].hdr.type]; const auto dsz = QueueDataSize[item[i].hdr.idx];
memcpy( ptr, item+i, dsz ); memcpy( ptr, item+i, dsz );
ptr += dsz; ptr += dsz;
} }

View File

@ -30,7 +30,11 @@ struct QueueZoneEnd
struct QueueHeader struct QueueHeader
{ {
QueueType type; union
{
QueueType type;
uint8_t idx;
};
int64_t time; int64_t time;
}; };

View File

@ -82,14 +82,14 @@ void View::Worker()
{ {
auto ev = (QueueItem*)ptr; auto ev = (QueueItem*)ptr;
Process( *ev ); Process( *ev );
ptr += QueueDataSize[(uint8_t)ev->hdr.type]; ptr += QueueDataSize[ev->hdr.idx];
} }
} }
else else
{ {
QueueItem hdr; QueueItem hdr;
if( !sock.Read( &hdr.hdr, sizeof( QueueHeader ), &tv, ShouldExit ) ) goto close; if( !sock.Read( &hdr.hdr, sizeof( QueueHeader ), &tv, ShouldExit ) ) goto close;
if( !sock.Read( ((char*)&hdr) + sizeof( QueueHeader ), QueueDataSize[(uint8_t)hdr.hdr.type] - sizeof( QueueHeader ), &tv, ShouldExit ) ) goto close; if( !sock.Read( ((char*)&hdr) + sizeof( QueueHeader ), QueueDataSize[hdr.hdr.idx] - sizeof( QueueHeader ), &tv, ShouldExit ) ) goto close;
Process( hdr ); Process( hdr );
} }
} }