From fdf3cd76468296251ef1e206569981fca33ca15c 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 3ce89b4f5..98a975bdb 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -476,6 +476,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;