mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-25 23:44:35 +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
@ -116,10 +116,18 @@ static inline void PrintSmallIntFrac( char*& buf, uint64_t v )
|
|||||||
uint64_t in = v / 1000;
|
uint64_t in = v / 1000;
|
||||||
uint64_t fr = v % 1000;
|
uint64_t fr = v % 1000;
|
||||||
if( fr >= 995 )
|
if( fr >= 995 )
|
||||||
|
{
|
||||||
|
if( in < 999 )
|
||||||
{
|
{
|
||||||
PrintSmallInt( buf, in+1 );
|
PrintSmallInt( buf, in+1 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
memcpy( buf, "1000", 4 );
|
||||||
|
buf += 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
PrintSmallInt( buf, in );
|
PrintSmallInt( buf, in );
|
||||||
if( fr > 5 )
|
if( fr > 5 )
|
||||||
|
Loading…
Reference in New Issue
Block a user