1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Search for a character in string in 8-byte blocks.

This commit is contained in:
Bartosz Taudul 2021-06-03 12:47:00 +02:00
parent 483d31c1f4
commit f8bb24ed36
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -1310,14 +1310,54 @@ ssize_t getline(char **buf, size_t *bufsiz, FILE *fp)
}
#endif
static inline void AdvanceTo( const char*& line, char match )
{
auto ptr = line;
for(;;)
{
uint64_t l;
memcpy( &l, ptr, 8 );
for( int i=0; i<8; i++ )
{
if( ( l & 0xFF ) == uint8_t( match ) )
{
line = ptr + i;
return;
}
l >>= 8;
}
ptr += 8;
}
}
static inline void AdvanceToNot( const char*& line, char match )
{
auto ptr = line;
for(;;)
{
uint64_t l;
memcpy( &l, ptr, 8 );
for( int i=0; i<8; i++ )
{
if( ( l & 0xFF ) != uint8_t( match ) )
{
line = ptr + i;
return;
}
l >>= 8;
}
ptr += 8;
}
}
static void HandleTraceLine( const char* line )
{
line += 23;
while( *line != '[' ) line++;
AdvanceTo( line, '[' );
line++;
const auto cpu = (uint8_t)ReadNumber( line );
line++; // ']'
while( *line == ' ' ) line++;
AdvanceToNot( line, ' ' );
#if defined TRACY_HW_TIMER && ( defined __i386 || defined _M_IX86 || defined __x86_64__ || defined _M_X64 )
const auto time = ReadNumber( line );