mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 06:34:36 +00:00
Fix time rounding logic.
PrintSmallInt() expects values in the 0-999 range, but the in+1 may produce 1000 here. This is invalid and it either asserted, or outputted an empty string. Workaround by simple outputting "1000" as the value here. This function is only used in context of printing time, and only in specific context. The end result will be that values like "1000 us" or "1000 ms" may appear, where they would be otherwise shortened to "1 ms" or "1 s". This may be a bit unusual, but is acceptable, as the real time value has not yet crossed the threshold required for such shortening.
This commit is contained in:
parent
f0386d2f72
commit
107975c8de
@ -117,7 +117,15 @@ static inline void PrintSmallIntFrac( char*& buf, uint64_t v )
|
|||||||
uint64_t fr = v % 1000;
|
uint64_t fr = v % 1000;
|
||||||
if( fr >= 995 )
|
if( fr >= 995 )
|
||||||
{
|
{
|
||||||
PrintSmallInt( buf, in+1 );
|
if( in < 999 )
|
||||||
|
{
|
||||||
|
PrintSmallInt( buf, in+1 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memcpy( buf, "1000", 4 );
|
||||||
|
buf += 4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user