Make smart_ulltoa return pointer to end (allows for code shink in callers)

function                                             old     new   delta
smart_ulltoa5                                        405     408      +3
smart_ulltoa4                                        273     276      +3
list_table                                          1113    1114      +1
scale                                                 36      34      -2
put_lu                                                55      53      -2
ulltoa6_and_space                                     19      14      -5
powertop_main                                       1470    1461      -9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2013-09-06 12:53:14 +02:00
parent d6ae4fb446
commit a407cf74cc
7 changed files with 14 additions and 20 deletions

View File

@@ -94,7 +94,7 @@ const char* FAST_FUNC make_human_readable_str(unsigned long long val,
/* Convert unsigned long long value into compact 5-char representation.
* String is not terminated (buf[5] is untouched) */
void FAST_FUNC smart_ulltoa5(unsigned long long ul, char buf[5], const char *scale)
char* FAST_FUNC smart_ulltoa5(unsigned long long ul, char buf[5], const char *scale)
{
const char *fmt;
char c;
@@ -145,12 +145,13 @@ void FAST_FUNC smart_ulltoa5(unsigned long long ul, char buf[5], const char *sca
buf[3] = "0123456789"[v];
buf[4] = scale[idx]; /* typically scale = " kmgt..." */
}
return buf + 5;
}
/* Convert unsigned long long value into compact 4-char
* representation. Examples: "1234", "1.2k", " 27M", "123T"
* String is not terminated (buf[4] is untouched) */
void FAST_FUNC smart_ulltoa4(unsigned long long ul, char buf[4], const char *scale)
char* FAST_FUNC smart_ulltoa4(unsigned long long ul, char buf[4], const char *scale)
{
const char *fmt;
char c;
@@ -194,4 +195,5 @@ void FAST_FUNC smart_ulltoa4(unsigned long long ul, char buf[4], const char *sca
buf[2] = "0123456789"[v];
buf[3] = scale[idx]; /* typically scale = " kmgt..." */
}
return buf + 4;
}