summaryrefslogtreecommitdiff
path: root/src/strings.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-08-05 16:14:40 +0000
committersmatz <smatz@openttd.org>2009-08-05 16:14:40 +0000
commit9dcdc14310cd2deb5be677464c40346a4b5195c0 (patch)
tree80cb37da5c14779af61e4e19cd68a823f822eefb /src/strings.cpp
parent808254c48894e010fc76870cf401da4a08ff233a (diff)
downloadopenttd-9dcdc14310cd2deb5be677464c40346a4b5195c0.tar.xz
(svn r17073) -Codechange: constify iec_prefixes[], change the code around a bit
Diffstat (limited to 'src/strings.cpp')
-rw-r--r--src/strings.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/strings.cpp b/src/strings.cpp
index add90ae26..c4b4a7cc2 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -244,8 +244,8 @@ static char *FormatBytes(char *buff, int64 number, const char *last)
{
assert(number >= 0);
- /* 0 2^10 2^20 2^30 2^40 2^50 2^60 */
- const char *siUnits[] = { "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB" };
+ /* 1 2^10 2^20 2^30 2^40 2^50 2^60 */
+ const char * const iec_prefixes[] = { "", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei" };
uint id = 1;
while (number >= 1024 * 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);
}
- assert(id < lengthof(siUnits));
- buff += seprintf(buff, last, " %s", siUnits[id]);
+ assert(id < lengthof(iec_prefixes));
+ buff += seprintf(buff, last, " %sB", iec_prefixes[id]);
return buff;
}