Mercurial > vim
comparison src/regexp_bt.c @ 29012:f9775679df1f v8.2.5028
patch 8.2.5028: syntax regexp matching can be slow
Commit: https://github.com/vim/vim/commit/02e8d4e4ffcdd6ee919e19692d591da8e18a565d
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri May 27 15:35:28 2022 +0100
patch 8.2.5028: syntax regexp matching can be slow
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 27 May 2022 16:45:04 +0200 |
parents | e25196adb7c1 |
children | b90bca860b5a |
comparison
equal
deleted
inserted
replaced
29011:922c555e7aad | 29012:f9775679df1f |
---|---|
3269 { | 3269 { |
3270 status = RA_FAIL; | 3270 status = RA_FAIL; |
3271 break; | 3271 break; |
3272 } | 3272 } |
3273 #ifdef FEAT_RELTIME | 3273 #ifdef FEAT_RELTIME |
3274 // Check for timeout once in a 100 times to avoid overhead. | 3274 // Check for timeout once in 250 times to avoid excessive overhead from |
3275 if (tm != NULL && ++tm_count == 100) | 3275 // reading the clock. The value has been picked to check about once |
3276 // per msec on a modern CPU. | |
3277 if (tm != NULL && ++tm_count == 250) | |
3276 { | 3278 { |
3277 tm_count = 0; | 3279 tm_count = 0; |
3278 if (profile_passed_limit(tm)) | 3280 if (profile_passed_limit(tm)) |
3279 { | 3281 { |
3280 if (timed_out != NULL) | 3282 if (timed_out != NULL) |
3311 next = regnext(scan); | 3313 next = regnext(scan); |
3312 | 3314 |
3313 op = OP(scan); | 3315 op = OP(scan); |
3314 // Check for character class with NL added. | 3316 // Check for character class with NL added. |
3315 if (!rex.reg_line_lbr && WITH_NL(op) && REG_MULTI | 3317 if (!rex.reg_line_lbr && WITH_NL(op) && REG_MULTI |
3316 && *rex.input == NUL && rex.lnum <= rex.reg_maxline) | 3318 && *rex.input == NUL && rex.lnum <= rex.reg_maxline) |
3317 { | 3319 { |
3318 reg_nextline(); | 3320 reg_nextline(); |
3319 } | 3321 } |
3320 else if (rex.reg_line_lbr && WITH_NL(op) && *rex.input == '\n') | 3322 else if (rex.reg_line_lbr && WITH_NL(op) && *rex.input == '\n') |
3321 { | 3323 { |
4988 if (has_mbyte) | 4990 if (has_mbyte) |
4989 col += (*mb_ptr2len)(rex.line + col); | 4991 col += (*mb_ptr2len)(rex.line + col); |
4990 else | 4992 else |
4991 ++col; | 4993 ++col; |
4992 #ifdef FEAT_RELTIME | 4994 #ifdef FEAT_RELTIME |
4993 // Check for timeout once in a twenty times to avoid overhead. | 4995 // Check for timeout once in 500 times to avoid excessive overhead |
4994 if (tm != NULL && ++tm_count == 20) | 4996 // from reading the clock. The value has been picked to check |
4997 // about once per msec on a modern CPU. | |
4998 if (tm != NULL && ++tm_count == 500) | |
4995 { | 4999 { |
4996 tm_count = 0; | 5000 tm_count = 0; |
4997 if (profile_passed_limit(tm)) | 5001 if (profile_passed_limit(tm)) |
4998 { | 5002 { |
4999 if (timed_out != NULL) | 5003 if (timed_out != NULL) |