commit f54d892e4b41b214bfbc655c9d9b72d8b2bf0f07 from: Mark Jamsek via: Thomas Adam date: Fri Feb 17 16:23:18 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 - 5330ab762909f51f51f564f8b8af9eac9c8f4354 commit + f54d892e4b41b214bfbc655c9d9b72d8b2bf0f07 blob - 344c266805e9013512993feb7f77e07dc537338f blob + 150f3c355688b24c83a7a03a635b993f8f20f5a2 --- tog/tog.c +++ tog/tog.c @@ -1293,7 +1293,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; @@ -1326,6 +1326,8 @@ view_search_start(struct tog_view *view) cbreak(); noecho(); nodelay(v->window, TRUE); + if (!fast_refresh) + halfdelay(10); if (ret == ERR) return NULL; @@ -1493,7 +1495,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; @@ -1688,7 +1690,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; @@ -1780,7 +1782,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;