]> granicus.if.org Git - procps-ng/commitdiff
top: lessen overhead when 'bottom window' isn't active
authorJim Warner <james.warner@comcast.net>
Wed, 11 Jan 2023 06:00:00 +0000 (00:00 -0600)
committerCraig Small <csmall@dropbear.xyz>
Sun, 15 Jan 2023 04:02:39 +0000 (15:02 +1100)
In the commits referenced below special code was added
to make the bottom window sticky and fix the bug after
'Cap_nl_clreos' was traded for the 'Cap_clr_eol' loop.

However, there's always major overhead associated with
interacting with a terminal. So we'll only abandon the
single 'Cap_nl_clreos' putp in favor of repeated calls
with 'Cap_clr_eol' when a bottom window isn't present.

Reference(s):
. May, 2022 - bottom window batch bug fix
commit 793f3e85aeb41788e359c2f6f387812c328ac097
. May, 2022 - bottom window made sticky
commit 0f2a755b0b2754fca79545984e25ec52f4ae4444

Signed-off-by: Jim Warner <james.warner@comcast.net>
src/top/top.c

index 390e92a07126e78e15cb0c63bff066e1aa7e9651..6cade5eff06aba3ef551559d5fe33ab9799ab5d0 100644 (file)
@@ -105,6 +105,7 @@ static int   Screen_cols, Screen_rows, Max_lines;
         /* These 'SCREEN_ROWS', 'BOT_ and 'Bot_' guys are used
            in managing the special separate bottom 'window' ... */
 #define      SCREEN_ROWS ( Screen_rows - Bot_rsvd )
+#define      BOT_PRESENT ( Bot_what > 0 )
 #define      BOT_ITEMMAX  10           // Bot_item array's max size
 #define      BOT_MSGSMAX  10           // total entries for Msg_tab
 #define      BOT_UNFOCUS  -1           // tab focus not established
@@ -5669,7 +5670,7 @@ static void keys_global (int ch) {
          bot_item_toggle(EU_CGR, N_fmt(X_BOT_ctlgrp_fmt), BOT_SEP_SLS);
          break;
       case kbd_CtrlI:
-         if (Bot_what) {
+         if (BOT_PRESENT) {
             ++Bot_indx;
             if (Bot_indx > Bot_focus_func(NULL, NULL))
                Bot_indx = BOT_UNFOCUS;
@@ -5719,7 +5720,7 @@ static void keys_global (int ch) {
          bot_item_toggle(EU_SGN, N_fmt(X_BOT_supgrp_fmt), BOT_SEP_CMA);
          break;
       case kbd_BTAB:
-         if (Bot_what) {
+         if (BOT_PRESENT) {
             --Bot_indx;
             num = Bot_focus_func(NULL, NULL);
             if (Bot_indx <= BOT_UNFOCUS)
@@ -7317,9 +7318,13 @@ static void frame_make (void) {
    /* clear to end-of-screen - critical if last window is 'idleps off'
       (main loop must iterate such that we're always called before sleep) */
    if (!Batch && scrlins < Max_lines) {
-      for (i = scrlins + Msg_row + 1; i < SCREEN_ROWS; i++) {
-         putp(tg2(0, i));
-         putp(Cap_clr_eol);
+      if (!BOT_PRESENT)
+         putp(Cap_nl_clreos);
+      else {
+         for (i = scrlins + Msg_row + 1; i < SCREEN_ROWS; i++) {
+            putp(tg2(0, i));
+            putp(Cap_clr_eol);
+         }
       }
       PSU_CLREOS(Pseudo_row);
    }