From 2db555914fabaf53b7d941f7ccc4e3fdaaa50289 Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Thu, 6 Jul 2017 13:40:33 -0400 Subject: [PATCH] report_clear() efficiency plus clear after grep 2b384f69b introduced a performance regression due to use of wclear(), which dirties the entire screen. The core issue being addressed in 2b384f69b is that readline can leave an incorrect cursor position in virtual window newscr. So, explicitly reset the newscr cursor position post-readline, which enables switching to the much more efficient werase() for erasing the status area. Incidentally fix the missed case of report_clear() after a grep prompt. --- src/display.c | 5 ++--- src/grep.c | 2 ++ src/prompt.c | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/display.c b/src/display.c index 125818478..7ea151c36 100644 --- a/src/display.c +++ b/src/display.c @@ -430,9 +430,8 @@ report_clear(void) return; if (!input_mode && !status_empty) { - wclear(status_win); - wclrtoeol(status_win); - wnoutrefresh(status_win); + werase(status_win); + doupdate(); } status_empty = true; update_view_title(view); diff --git a/src/grep.c b/src/grep.c index e4228467d..cf9feb027 100644 --- a/src/grep.c +++ b/src/grep.c @@ -99,6 +99,8 @@ grep_prompt(void) int argc = 0; char *grep = read_prompt("grep: "); + report_clear(); + if (!grep || !argv_from_string_no_quotes(argv, &argc, grep)) return false; if (grep_argv) diff --git a/src/prompt.c b/src/prompt.c index 40fc3db4f..6f995009e 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -474,6 +474,9 @@ read_prompt(const char *prompt) if (signal(SIGINT, SIG_DFL) == SIG_ERR) die("Failed to remove sigint handler"); + /* readline can leave the virtual cursor out-of-place */ + set_cursor_pos(0, 0); + if (line && !*line) { free(line); line = NULL;