summaryrefslogtreecommitdiff
path: root/src/regexp_bt.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-05-27 15:35:28 +0100
committerBram Moolenaar <Bram@vim.org>2022-05-27 15:35:28 +0100
commit02e8d4e4ffcdd6ee919e19692d591da8e18a565d (patch)
treec8c1beb22eaee3ccfece6beb09c0620b20f5b80f /src/regexp_bt.c
parentbf79a4e48d09a5ae08645592885d54230fed30b8 (diff)
downloadvim-git-02e8d4e4ffcdd6ee919e19692d591da8e18a565d.tar.gz
patch 8.2.5028: syntax regexp matching can be slowv8.2.5028
Problem: Syntax regexp matching can be slow. Solution: Adjust the counters for checking the timeout to check about once per msec. (closes #10487, closes #2712)
Diffstat (limited to 'src/regexp_bt.c')
-rw-r--r--src/regexp_bt.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/regexp_bt.c b/src/regexp_bt.c
index 698ff043e..5bf0e0c4e 100644
--- a/src/regexp_bt.c
+++ b/src/regexp_bt.c
@@ -3271,8 +3271,10 @@ regmatch(
break;
}
#ifdef FEAT_RELTIME
- // Check for timeout once in a 100 times to avoid overhead.
- if (tm != NULL && ++tm_count == 100)
+ // Check for timeout once in 250 times to avoid excessive overhead from
+ // reading the clock. The value has been picked to check about once
+ // per msec on a modern CPU.
+ if (tm != NULL && ++tm_count == 250)
{
tm_count = 0;
if (profile_passed_limit(tm))
@@ -3313,7 +3315,7 @@ regmatch(
op = OP(scan);
// Check for character class with NL added.
if (!rex.reg_line_lbr && WITH_NL(op) && REG_MULTI
- && *rex.input == NUL && rex.lnum <= rex.reg_maxline)
+ && *rex.input == NUL && rex.lnum <= rex.reg_maxline)
{
reg_nextline();
}
@@ -4990,8 +4992,10 @@ bt_regexec_both(
else
++col;
#ifdef FEAT_RELTIME
- // Check for timeout once in a twenty times to avoid overhead.
- if (tm != NULL && ++tm_count == 20)
+ // Check for timeout once in 500 times to avoid excessive overhead
+ // from reading the clock. The value has been picked to check
+ // about once per msec on a modern CPU.
+ if (tm != NULL && ++tm_count == 500)
{
tm_count = 0;
if (profile_passed_limit(tm))