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
2ceb1c74d5.
This commit is contained in:
David Bürgin
2015-05-09 20:06:54 +02:00
committed by Justin M. Keyes
parent 2498314876
commit de6b3fbb15
2 changed files with 18 additions and 3 deletions

View File

@@ -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_GT:
case NFA_VCOL_LT: 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, uintmax_t lts = win_linetabsize(reg_win == NULL ? curwin : reg_win,
regline, regline,
(colnr_T)(reginput - regline)); col);
assert(t->state->val >= 0); assert(t->state->val >= 0);
result = nfa_re_num_cmp((uintmax_t)t->state->val, result = nfa_re_num_cmp((uintmax_t)t->state->val,
t->state->c - NFA_VCOL, op,
lts + 1); lts + 1);
if (result) { if (result) {
add_here = TRUE; add_here = TRUE;
@@ -6023,6 +6032,12 @@ nextchar:
reg_nextline(); reg_nextline();
else else
break; break;
// Allow interrupting with CTRL-C.
fast_breakcheck();
if (got_int) {
break;
}
} }
#ifdef REGEXP_DEBUG #ifdef REGEXP_DEBUG

View File

@@ -206,7 +206,7 @@ static int included_patches[] = {
580, 580,
//579, //579,
578, 578,
//577, 577,
576, 576,
//575, //575,
574, 574,