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

Use string end pointer.

This commit is contained in:
Bartosz Taudul 2022-08-15 14:54:23 +02:00
parent d91321a774
commit 0c6acf3c2e
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -835,21 +835,24 @@ const char* View::ShortenZoneName( const char* name, ImVec2& tsz, float zsz ) co
static char buf[64*1024];
char tmp[64*1024];
auto end = name;
while( *end ) end++;
auto ptr = name;
auto dst = tmp;
int cnt = 0;
for(;;)
{
auto start = ptr;
while( *ptr && *ptr != '<' ) ptr++;
while( ptr < end && *ptr != '<' ) ptr++;
memcpy( dst, start, ptr - start + 1 );
if( !*ptr ) break;
dst += ptr - start + 1;
if( ptr == end ) break;
cnt++;
ptr++;
while( cnt > 0 )
{
if( !*ptr ) break;
if( ptr == end ) break;
if( *ptr == '<' ) cnt++;
else if( *ptr == '>' ) cnt--;
ptr++;
@ -857,21 +860,22 @@ const char* View::ShortenZoneName( const char* name, ImVec2& tsz, float zsz ) co
*dst++ = '>';
}
end = dst;
ptr = tmp;
dst = buf;
cnt = 0;
for(;;)
{
auto start = ptr;
while( *ptr && *ptr != '(' ) ptr++;
while( ptr < end && *ptr != '(' ) ptr++;
memcpy( dst, start, ptr - start + 1 );
if( !*ptr ) break;
dst += ptr - start + 1;
if( ptr == end ) break;
cnt++;
ptr++;
while( cnt > 0 )
{
if( !*ptr ) break;
if( ptr == end ) break;
if( *ptr == '(' ) cnt++;
else if( *ptr == ')' ) cnt--;
ptr++;