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)
diff --git a/src/match.c b/src/match.c
index 8280da7..7227652 100644
--- a/src/match.c
+++ b/src/match.c
@@ -330,10 +330,6 @@
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 @@
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 @@
{
# 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 @@
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;