diff options
author | Jim Warner <james.warner@comcast.net> | 2020-07-08 00:00:00 -0500 |
---|---|---|
committer | Craig Small <csmall@dropbear.xyz> | 2020-07-20 16:15:14 +1000 |
commit | 3e2cd9f87b054999b8d38a5243aec26e7becf858 (patch) | |
tree | 494b7e785a2b7bee109dd782d8492ceea97c10f4 | |
parent | 8c115f6cf32c52a99dabd827c7c40634875cc8b9 (diff) | |
download | procps-ng-3e2cd9f87b054999b8d38a5243aec26e7becf858.tar.gz |
top: make the 'cpu_tics' function a tad more efficient
This patch eliminates one variable which resulted in a
corresponding elimination of three 'mov' instructions.
[ that was 6 bytes per 'mov' for a total of 18 bytes ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
-rw-r--r-- | top/top.c | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -5348,7 +5348,6 @@ static int cpu_tics (struct stat_stack *this, const char *pfx, int nobuf) { #define rSv(E) TIC_VAL(E, this) SIC_t idl_frme, tot_frme; float scale; - int n; idl_frme = rSv(stat_IL); tot_frme = rSv(stat_SUM_TOT); @@ -5379,16 +5378,15 @@ static int cpu_tics (struct stat_stack *this, const char *pfx, int nobuf) { snprintf(syst, sizeof(syst), gtab[ix].syst, (int)((pct_syst * Graph_adj) + .4), gtab[ix].type); #endif snprintf(dual, sizeof(dual), "%s%s", user, syst); - n = cpu_prt(fmtmk("%s ~3%#5.1f~2/%-#5.1f~3 %3.0f[~1%-*s]~1" + return cpu_prt(fmtmk("%s ~3%#5.1f~2/%-#5.1f~3 %3.0f[~1%-*s]~1" , pfx, pct_user, pct_syst, pct_user + pct_syst, Graph_len +4, dual), nobuf); } else { - n = cpu_prt(fmtmk(Cpu_States_fmts, pfx + return cpu_prt(fmtmk(Cpu_States_fmts, pfx , (float)rSv(stat_US) * scale, (float)rSv(stat_SY) * scale , (float)rSv(stat_NI) * scale, (float)idl_frme * scale , (float)rSv(stat_IO) * scale, (float)rSv(stat_IR) * scale , (float)rSv(stat_SI) * scale, (float)rSv(stat_ST) * scale), nobuf); } - return n; #undef rSv } // end: cpu_tics |