From de6b3fbb1590bff0bb49e57579980d62bb514103 Mon Sep 17 00:00:00 2001 From: David Bürgin <676c7473@gmail.com> Date: Sat, 9 May 2015 20:06:54 +0200 Subject: 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. --- src/nvim/regexp_nfa.c | 19 +++++++++++++++++-- src/nvim/version.c | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'src') 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, -- cgit