aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Bürgin <676c7473@gmail.com>2015-05-09 20:06:54 +0200
committerJustin M. Keyes <justinkz@gmail.com>2015-05-13 03:10:24 -0400
commitde6b3fbb1590bff0bb49e57579980d62bb514103 (patch)
tree07ee4175a38ace3de75269e8f614f44c3fe868cb /src
parent24983148765868dbcd598b507f5d3160326b1087 (diff)
downloadrneovim-de6b3fbb1590bff0bb49e57579980d62bb514103.tar.gz
rneovim-de6b3fbb1590bff0bb49e57579980d62bb514103.tar.bz2
rneovim-de6b3fbb1590bff0bb49e57579980d62bb514103.zip
vim-patch:7.4.577
Problem: Matching with a virtual column has a lot of overhead on very long lines. (Issue 310) Solution: Bail out early if there can't be a match. (Christian Brabandt) Also check for CTRL-C at every position. https://github.com/vim/vim/commit/v7-4-577 See also https://code.google.com/p/vim/issues/detail?id=310 Slightly adapted due to the long_u refactoring in 2ceb1c74d591a07183ee02baf6ff1e205c87c6b8.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/regexp_nfa.c19
-rw-r--r--src/nvim/version.c2
2 files changed, 18 insertions, 3 deletions
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index 3daf6a8544..21feb87ae1 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -5737,12 +5737,21 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm
case NFA_VCOL_GT:
case NFA_VCOL_LT:
{
+ int op = t->state->c - NFA_VCOL;
+ colnr_T col = (colnr_T)(reginput - regline);
+
+ // Bail out quickly when there can't be a match, avoid the overhead of
+ // win_linetabsize() on long lines.
+ if ((col > t->state->val && op != 1)
+ || (col - 1 > t->state->val && op == 1)) {
+ break;
+ }
uintmax_t lts = win_linetabsize(reg_win == NULL ? curwin : reg_win,
regline,
- (colnr_T)(reginput - regline));
+ col);
assert(t->state->val >= 0);
result = nfa_re_num_cmp((uintmax_t)t->state->val,
- t->state->c - NFA_VCOL,
+ op,
lts + 1);
if (result) {
add_here = TRUE;
@@ -6023,6 +6032,12 @@ nextchar:
reg_nextline();
else
break;
+
+ // Allow interrupting with CTRL-C.
+ fast_breakcheck();
+ if (got_int) {
+ break;
+ }
}
#ifdef REGEXP_DEBUG
diff --git a/src/nvim/version.c b/src/nvim/version.c
index e3c2ee9e99..e786b2ffca 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -206,7 +206,7 @@ static int included_patches[] = {
580,
//579,
578,
- //577,
+ 577,
576,
//575,
574,