Avoid "else" trick with #ifdef, hopefully makes code easier to follow.

This commit is contained in:
Hisham Muhammad 2014-04-09 23:14:41 -03:00
parent 5d6ad853fa
commit 96858744b5
1 changed files with 11 additions and 7 deletions

View File

@ -335,34 +335,38 @@ static void Process_humanNumber(Process* this, RichString* str, unsigned long nu
if(number >= (100 * ONE_DECIMAL_G)) { if(number >= (100 * ONE_DECIMAL_G)) {
len = snprintf(buffer, 10, "%4ldT ", number / ONE_G); len = snprintf(buffer, 10, "%4ldT ", number / ONE_G);
RichString_appendn(str, CRT_colors[LARGE_NUMBER], buffer, len); RichString_appendn(str, CRT_colors[LARGE_NUMBER], buffer, len);
return;
} else if (number >= (1000 * ONE_DECIMAL_M)) { } else if (number >= (1000 * ONE_DECIMAL_M)) {
len = snprintf(buffer, 10, "%3.1lfT ", (double)number / ONE_G); len = snprintf(buffer, 10, "%3.1lfT ", (double)number / ONE_G);
RichString_appendn(str, CRT_colors[LARGE_NUMBER], buffer, len); RichString_appendn(str, CRT_colors[LARGE_NUMBER], buffer, len);
} else return;
}
#endif #endif
if(number >= (100 * ONE_DECIMAL_M)) { if(number >= (100 * ONE_DECIMAL_M)) {
len = snprintf(buffer, 10, "%4ldG ", number / ONE_M); len = snprintf(buffer, 10, "%4ldG ", number / ONE_M);
RichString_appendn(str, CRT_colors[LARGE_NUMBER], buffer, len); RichString_appendn(str, CRT_colors[LARGE_NUMBER], buffer, len);
} else { return;
len = snprintf(buffer, 10, "%3.1lfG ", (double)number / ONE_M);
RichString_appendn(str, CRT_colors[LARGE_NUMBER], buffer, len);
} }
len = snprintf(buffer, 10, "%3.1lfG ", (double)number / ONE_M);
RichString_appendn(str, CRT_colors[LARGE_NUMBER], buffer, len);
return;
} else if (number >= 100000) { } else if (number >= 100000) {
len = snprintf(buffer, 10, "%4ldM ", number / ONE_K); len = snprintf(buffer, 10, "%4ldM ", number / ONE_K);
int attr = this->pl->highlightMegabytes int attr = this->pl->highlightMegabytes
? CRT_colors[PROCESS_MEGABYTES] ? CRT_colors[PROCESS_MEGABYTES]
: CRT_colors[PROCESS]; : CRT_colors[PROCESS];
RichString_appendn(str, attr, buffer, len); RichString_appendn(str, attr, buffer, len);
return;
} else if (this->pl->highlightMegabytes && number >= 1000) { } else if (this->pl->highlightMegabytes && number >= 1000) {
len = snprintf(buffer, 10, "%2ld", number/1000); len = snprintf(buffer, 10, "%2ld", number/1000);
RichString_appendn(str, CRT_colors[PROCESS_MEGABYTES], buffer, len); RichString_appendn(str, CRT_colors[PROCESS_MEGABYTES], buffer, len);
number %= 1000; number %= 1000;
len = snprintf(buffer, 10, "%03ld ", number); len = snprintf(buffer, 10, "%03ld ", number);
RichString_appendn(str, CRT_colors[PROCESS], buffer, len); RichString_appendn(str, CRT_colors[PROCESS], buffer, len);
} else { return;
len = snprintf(buffer, 10, "%5ld ", number);
RichString_appendn(str, CRT_colors[PROCESS], buffer, len);
} }
len = snprintf(buffer, 10, "%5ld ", number);
RichString_appendn(str, CRT_colors[PROCESS], buffer, len);
} }
static void Process_colorNumber(RichString* str, unsigned long long number) { static void Process_colorNumber(RichString* str, unsigned long long number) {