Skip to content

Commit

Permalink
report_clear() efficiency plus clear after grep
Browse files Browse the repository at this point in the history
2b384f6 introduced a performance regression due to use of wclear(),
which dirties the entire screen.  The core issue being addressed in
2b384f6 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.
  • Loading branch information
rolandwalker authored and jonas committed Jul 6, 2017
1 parent 809a2af commit fdf3cd7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions src/prompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fdf3cd7

Please sign in to comment.