Changeset - r12620:f524f9555096
[Not reviewed]
master
0 1 0
smatz - 15 years ago 2009-08-05 16:14:40
smatz@openttd.org
(svn r17073) -Codechange: constify iec_prefixes[], change the code around a bit
1 file changed with 4 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/strings.cpp
Show inline comments
 
@@ -244,8 +244,8 @@ static char *FormatBytes(char *buff, int
 
{
 
	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, int
 
		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;
 
}
0 comments (0 inline, 0 general)