mirror of
https://github.com/wolfpld/tracy
synced 2025-04-30 20:53:52 +00:00
Use string end pointer.
This commit is contained in:
parent
d91321a774
commit
0c6acf3c2e
@ -835,21 +835,24 @@ const char* View::ShortenZoneName( const char* name, ImVec2& tsz, float zsz ) co
|
|||||||
static char buf[64*1024];
|
static char buf[64*1024];
|
||||||
char tmp[64*1024];
|
char tmp[64*1024];
|
||||||
|
|
||||||
|
auto end = name;
|
||||||
|
while( *end ) end++;
|
||||||
|
|
||||||
auto ptr = name;
|
auto ptr = name;
|
||||||
auto dst = tmp;
|
auto dst = tmp;
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
auto start = ptr;
|
auto start = ptr;
|
||||||
while( *ptr && *ptr != '<' ) ptr++;
|
while( ptr < end && *ptr != '<' ) ptr++;
|
||||||
memcpy( dst, start, ptr - start + 1 );
|
memcpy( dst, start, ptr - start + 1 );
|
||||||
if( !*ptr ) break;
|
|
||||||
dst += ptr - start + 1;
|
dst += ptr - start + 1;
|
||||||
|
if( ptr == end ) break;
|
||||||
cnt++;
|
cnt++;
|
||||||
ptr++;
|
ptr++;
|
||||||
while( cnt > 0 )
|
while( cnt > 0 )
|
||||||
{
|
{
|
||||||
if( !*ptr ) break;
|
if( ptr == end ) break;
|
||||||
if( *ptr == '<' ) cnt++;
|
if( *ptr == '<' ) cnt++;
|
||||||
else if( *ptr == '>' ) cnt--;
|
else if( *ptr == '>' ) cnt--;
|
||||||
ptr++;
|
ptr++;
|
||||||
@ -857,21 +860,22 @@ const char* View::ShortenZoneName( const char* name, ImVec2& tsz, float zsz ) co
|
|||||||
*dst++ = '>';
|
*dst++ = '>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end = dst;
|
||||||
ptr = tmp;
|
ptr = tmp;
|
||||||
dst = buf;
|
dst = buf;
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
auto start = ptr;
|
auto start = ptr;
|
||||||
while( *ptr && *ptr != '(' ) ptr++;
|
while( ptr < end && *ptr != '(' ) ptr++;
|
||||||
memcpy( dst, start, ptr - start + 1 );
|
memcpy( dst, start, ptr - start + 1 );
|
||||||
if( !*ptr ) break;
|
|
||||||
dst += ptr - start + 1;
|
dst += ptr - start + 1;
|
||||||
|
if( ptr == end ) break;
|
||||||
cnt++;
|
cnt++;
|
||||||
ptr++;
|
ptr++;
|
||||||
while( cnt > 0 )
|
while( cnt > 0 )
|
||||||
{
|
{
|
||||||
if( !*ptr ) break;
|
if( ptr == end ) break;
|
||||||
if( *ptr == '(' ) cnt++;
|
if( *ptr == '(' ) cnt++;
|
||||||
else if( *ptr == ')' ) cnt--;
|
else if( *ptr == ')' ) cnt--;
|
||||||
ptr++;
|
ptr++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user