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

Use memchr() to find newline in memory block.

This commit is contained in:
Bartosz Taudul 2020-08-18 19:51:02 +02:00
parent 48062573b8
commit 4d4b6c7ac9

View File

@ -1102,19 +1102,16 @@ static void ProcessTraceLines( int fd )
line = buf; line = buf;
for(;;) for(;;)
{ {
auto next = line; auto next = (char*)memchr( line, '\n', end - line );
while( next < end && *next != '\n' ) next++; if( !next )
next++;
if( next >= end )
{ {
const auto lsz = end - line; const auto lsz = end - line;
memmove( buf, line, lsz ); memmove( buf, line, lsz );
line = buf + lsz; line = buf + lsz;
break; break;
} }
HandleTraceLine( line ); HandleTraceLine( line );
line = next; line = ++next;
} }
if( rd < 64*1024 ) if( rd < 64*1024 )
{ {
@ -1189,14 +1186,10 @@ static void ProcessTraceLines( int fd )
const auto end = buf + rd; const auto end = buf + rd;
for(;;) for(;;)
{ {
auto next = line; auto next = (char*)memchr( line, '\n', end - line );
while( next < end && *next != '\n' ) next++; if( !next ) break;
if( next == end ) break;
assert( *next == '\n' );
next++;
HandleTraceLine( line ); HandleTraceLine( line );
line = next; line = ++next;
} }
} }