public: avoid useless copies in Q_pretifymem
This commit is contained in:
parent
844af709c0
commit
59b9b31604
1 changed files with 9 additions and 6 deletions
|
@ -410,9 +410,9 @@ char *Q_pretifymem( float value, int digitsafterdecimal )
|
||||||
{
|
{
|
||||||
static char output[8][32];
|
static char output[8][32];
|
||||||
static int current;
|
static int current;
|
||||||
float onekb = 1024.0f;
|
const float onekb = 1024.0f;
|
||||||
float onemb = onekb * onekb;
|
const float onemb = onekb * onekb;
|
||||||
char suffix[8];
|
const char *suffix;
|
||||||
char *out = output[current];
|
char *out = output[current];
|
||||||
char val[32], *i, *o, *dot;
|
char val[32], *i, *o, *dot;
|
||||||
int pos;
|
int pos;
|
||||||
|
@ -423,14 +423,17 @@ char *Q_pretifymem( float value, int digitsafterdecimal )
|
||||||
if( value > onemb )
|
if( value > onemb )
|
||||||
{
|
{
|
||||||
value /= onemb;
|
value /= onemb;
|
||||||
Q_strncpy( suffix, " Mb", sizeof( suffix ));
|
suffix = " Mb";
|
||||||
}
|
}
|
||||||
else if( value > onekb )
|
else if( value > onekb )
|
||||||
{
|
{
|
||||||
value /= onekb;
|
value /= onekb;
|
||||||
Q_strncpy( suffix, " Kb", sizeof( suffix ));
|
suffix = " Kb";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
suffix = " bytes";
|
||||||
}
|
}
|
||||||
else Q_strncpy( suffix, " bytes", sizeof( suffix ));
|
|
||||||
|
|
||||||
// clamp to >= 0
|
// clamp to >= 0
|
||||||
digitsafterdecimal = Q_max( digitsafterdecimal, 0 );
|
digitsafterdecimal = Q_max( digitsafterdecimal, 0 );
|
||||||
|
|
Loading…
Add table
Reference in a new issue