mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-11 14:42:05 +08:00
public: avoid useless copies in Q_pretifymem
This commit is contained in:
+9
-6
@@ -410,9 +410,9 @@ char *Q_pretifymem( float value, int digitsafterdecimal )
|
||||
{
|
||||
static char output[8][32];
|
||||
static int current;
|
||||
float onekb = 1024.0f;
|
||||
float onemb = onekb * onekb;
|
||||
char suffix[8];
|
||||
const float onekb = 1024.0f;
|
||||
const float onemb = onekb * onekb;
|
||||
const char *suffix;
|
||||
char *out = output[current];
|
||||
char val[32], *i, *o, *dot;
|
||||
int pos;
|
||||
@@ -423,14 +423,17 @@ char *Q_pretifymem( float value, int digitsafterdecimal )
|
||||
if( value > onemb )
|
||||
{
|
||||
value /= onemb;
|
||||
Q_strncpy( suffix, " Mb", sizeof( suffix ));
|
||||
suffix = " Mb";
|
||||
}
|
||||
else if( 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
|
||||
digitsafterdecimal = Q_max( digitsafterdecimal, 0 );
|
||||
|
||||
Reference in New Issue
Block a user