From 2db582e31ebf06ff05355809749351a4131e0628 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Wed, 28 Nov 2012 00:00:00 -0600 Subject: [PATCH] top: give inspect display page algorithm a small boost This commit improves display performance when the user has scrolled horizontally past the end of a top 'row'. We can avoid the need to memset our buffer with spaces and putp those spaces individually by exploiting logic that already exists. If one '\n' character is inserted into the buffer instead, the next terminfo string sent will be Cap_clr_eol achieving exactly the same effect! (now that we know a '.' + 2 spaces is squeezed to one) (everything's perfectly justified, but it's just luck) Signed-off-by: Jim Warner --- top/top.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/top/top.c b/top/top.c index cfa98b82..cd5785b3 100644 --- a/top/top.c +++ b/top/top.c @@ -2514,7 +2514,7 @@ static void insp_find (int ch, int *col, int *row) { /* * This guy is an insp_view_this() *Helper* function responsible - * for positioning us in both the x/y axes within the former glob + * for positioning us in both the x/y axes within the current glob * and displaying a page worth of damages. Along the way, he makes * sure that any control characters and/or unprintable characters * use a less-like approach which distinguishes between two forms @@ -2550,10 +2550,11 @@ static inline void insp_show_pg (int col, int row, int max) { capNO; putp("\n"); - memset(tline, ' ', sizeof(tline)); len = INSP_RLEN(row); if (col < len) memcpy(tline, Insp_p[row] + col, sizeof(tline)); + else tline[0] = '\n'; + for (fr = 0, to = 0; fr < len && to < Screen_cols; fr++) { unsigned char uch = tline[fr]; if (uch == '\n') break; // a no show (he,he)