From 3eab8059125f9aa69e0a5c6523abd52e9df9761b Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Tue, 27 Jun 2017 19:14:47 -0400 Subject: [PATCH] perf: throttle screen updates during load * blame: every 5 percent * line-oriented: every 100 lines --- src/blame.c | 2 +- src/view.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/blame.c b/src/blame.c index 86f646826..6df2a09e1 100644 --- a/src/blame.c +++ b/src/blame.c @@ -285,7 +285,7 @@ blame_read(struct view *view, struct buffer *buf, bool force_stop) if (!state->commit) { state->commit = read_blame_commit(view, buf->data, state); string_format(view->ref, "%s %2zd%%", view->vid, - view->lines ? state->blamed * 100 / view->lines : 0); + view->lines ? 5 * (size_t) (state->blamed * 20 / view->lines) : 0); } else if (parse_blame_info(state->commit, state->author, buf->data)) { bool update_view_columns = true; diff --git a/src/view.c b/src/view.c index 2431a9d3d..fff9c5c9b 100644 --- a/src/view.c +++ b/src/view.c @@ -665,7 +665,10 @@ update_view_title(struct view *view) wprintw(window, " - %s %d of %zd", view->ops->type, line->lineno, - view->lines - view->custom_lines); + MAX(line->lineno, + view->pipe + ? 100 * (size_t) ((view->lines - view->custom_lines) / 100) + : view->lines - view->custom_lines)); } if (view->pipe) {