commit 602eda794f1d6ffa7bf52408686191499e971da3 from: Mark Jamsek date: Thu Feb 09 06:10:07 2023 UTC tog: reset 1 second refresh rate after starting search This fixes an issue reported by Mikhail where CPU usage continuously increases if search is started after the refresh rate has dropped from 100ms to 1s by resetting the 1s refresh rate if search is started after fast initialisation has finished. This is not needed in limit_log_view() because the 1s refresh rate is reset in draw_commits() once the screen is redrawn (i.e., commits_needed == 0). Tested by and based on initial patch from Mikhail. ok stsp@ commit - 2ec74a9e9c334f3245765a6e6f35b7977f5b420e commit + 602eda794f1d6ffa7bf52408686191499e971da3 blob - a6351da680ffacc2f47bf1a42b494d77af0b4a3a blob + 59f6749677b14d49ad79028572ac387a766ff9db --- tog/tog.c +++ tog/tog.c @@ -1288,7 +1288,7 @@ tog_resizeterm(void) } static const struct got_error * -view_search_start(struct tog_view *view) +view_search_start(struct tog_view *view, int fast_refresh) { const struct got_error *err = NULL; struct tog_view *v = view; @@ -1321,6 +1321,8 @@ view_search_start(struct tog_view *view) cbreak(); noecho(); nodelay(v->window, TRUE); + if (!fast_refresh) + halfdelay(10); if (ret == ERR) return NULL; @@ -1488,7 +1490,7 @@ action_report(struct tog_view *view) static const struct got_error * view_input(struct tog_view **new, int *done, struct tog_view *view, - struct tog_view_list_head *views) + struct tog_view_list_head *views, int fast_refresh) { const struct got_error *err = NULL; struct tog_view *v; @@ -1683,7 +1685,7 @@ view_input(struct tog_view **new, int *done, struct to case '/': view->count = 0; if (view->search_start) - view_search_start(view); + view_search_start(view, fast_refresh); else err = view->input(new, view, ch); break; @@ -1775,7 +1777,7 @@ view_loop(struct tog_view *view) if (fast_refresh && --fast_refresh == 0) halfdelay(10); /* switch to once per second */ - err = view_input(&new_view, &done, view, &views); + err = view_input(&new_view, &done, view, &views, fast_refresh); if (err) break;