From 246c5fa8126556708c4537f618f61a31adeef43f Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Wed, 8 Jul 2020 00:00:00 -0500 Subject: [PATCH] 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 --- top/top.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/top/top.c b/top/top.c index 3dc55a6b..12eddfd7 100644 --- a/top/top.c +++ b/top/top.c @@ -5768,7 +5768,6 @@ static int cpu_tics (CPU_t *cpu, const char *pfx, int nobuf) { // user syst nice idle wait hirg sirq steal SIC_t u_frme, s_frme, n_frme, i_frme, w_frme, x_frme, y_frme, z_frme, tot_frme, tz; float scale; - int n; u_frme = TRIMz(cpu->cur.u - cpu->sav.u); s_frme = TRIMz(cpu->cur.s - cpu->sav.s); @@ -5810,16 +5809,15 @@ static int cpu_tics (CPU_t *cpu, 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)u_frme * scale, (float)s_frme * scale , (float)n_frme * scale, (float)i_frme * scale , (float)w_frme * scale, (float)x_frme * scale , (float)y_frme * scale, (float)z_frme * scale), nobuf); } - return n; #undef TRIMz } // end: cpu_tics