0
0
mirror of https://github.com/vim/vim.git synced 2025-10-28 09:27:14 -04:00

patch 8.2.5057: using gettimeofday() for timeout is very inefficient

Problem:    Using gettimeofday() for timeout is very inefficient.
Solution:   Set a platform dependent timer. (Paul Ollis, closes #10505)
This commit is contained in:
Paul Ollis
2022-06-05 16:55:54 +01:00
committed by Bram Moolenaar
parent 1d97db3d98
commit 6574577cac
29 changed files with 811 additions and 242 deletions

View File

@@ -330,10 +330,6 @@ init_search_hl(win_T *wp, match_T *search_hl)
cur->hl.buf = wp->w_buffer;
cur->hl.lnum = 0;
cur->hl.first_lnum = 0;
# ifdef FEAT_RELTIME
// Set the time limit to 'redrawtime'.
profile_setlimit(p_rdt, &(cur->hl.tm));
# endif
cur = cur->next;
}
search_hl->buf = wp->w_buffer;
@@ -424,6 +420,7 @@ next_search_hl(
colnr_T matchcol;
long nmatched;
int called_emsg_before = called_emsg;
int timed_out = FALSE;
// for :{range}s/pat only highlight inside the range
if ((lnum < search_first_line || lnum > search_last_line) && cur == NULL)
@@ -451,7 +448,7 @@ next_search_hl(
{
# ifdef FEAT_RELTIME
// Stop searching after passing the time limit.
if (profile_passed_limit(&(shl->tm)))
if (timed_out)
{
shl->lnum = 0; // no match found in time
break;
@@ -494,16 +491,9 @@ next_search_hl(
int regprog_is_copy = (shl != search_hl && cur != NULL
&& shl == &cur->hl
&& cur->match.regprog == cur->hl.rm.regprog);
int timed_out = FALSE;
nmatched = vim_regexec_multi(&shl->rm, win, shl->buf, lnum,
matchcol,
#ifdef FEAT_RELTIME
&(shl->tm), &timed_out
#else
NULL, NULL
#endif
);
matchcol, &timed_out);
// Copy the regprog, in case it got freed and recompiled.
if (regprog_is_copy)
cur->match.regprog = cur->hl.rm.regprog;