mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-02 09:40:35 +00:00
(svn r17073) -Codechange: constify iec_prefixes[], change the code around a bit
This commit is contained in:
parent
8b743d3a69
commit
b0c4a09301
@ -244,8 +244,8 @@ static char *FormatBytes(char *buff, int64 number, const char *last)
|
|||||||
{
|
{
|
||||||
assert(number >= 0);
|
assert(number >= 0);
|
||||||
|
|
||||||
/* 0 2^10 2^20 2^30 2^40 2^50 2^60 */
|
/* 1 2^10 2^20 2^30 2^40 2^50 2^60 */
|
||||||
const char *siUnits[] = { "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB" };
|
const char * const iec_prefixes[] = { "", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei" };
|
||||||
uint id = 1;
|
uint id = 1;
|
||||||
while (number >= 1024 * 1024) {
|
while (number >= 1024 * 1024) {
|
||||||
number /= 1024;
|
number /= 1024;
|
||||||
@ -264,8 +264,8 @@ static char *FormatBytes(char *buff, int64 number, const char *last)
|
|||||||
buff += seprintf(buff, last, "%i", (int)number / 1024);
|
buff += seprintf(buff, last, "%i", (int)number / 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(id < lengthof(siUnits));
|
assert(id < lengthof(iec_prefixes));
|
||||||
buff += seprintf(buff, last, " %s", siUnits[id]);
|
buff += seprintf(buff, last, " %sB", iec_prefixes[id]);
|
||||||
|
|
||||||
return buff;
|
return buff;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user