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:
Bartosz Taudul 2022-08-28 14:44:41 +02:00
parent f0386d2f72
commit 107975c8de
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -117,7 +117,15 @@ static inline void PrintSmallIntFrac( char*& buf, uint64_t v )
uint64_t fr = v % 1000;
if( fr >= 995 )
{
PrintSmallInt( buf, in+1 );
if( in < 999 )
{
PrintSmallInt( buf, in+1 );
}
else
{
memcpy( buf, "1000", 4 );
buf += 4;
}
}
else
{