1
0
forked from aniani/vim

updated for version 7.3.1131

Problem:    New regexp engine is a bit slow.
Solution:   Do not clear the state list.  Don't copy syntax submatches when
            not used.
This commit is contained in:
Bram Moolenaar
2013-06-06 16:22:06 +02:00
parent f751255283
commit 188c57bcd1
2 changed files with 13 additions and 10 deletions

View File

@@ -319,7 +319,6 @@ nfa_regcomp_start(expr, re_flags)
post_start = (int *)lalloc(postfix_size, TRUE); post_start = (int *)lalloc(postfix_size, TRUE);
if (post_start == NULL) if (post_start == NULL)
return FAIL; return FAIL;
vim_memset(post_start, 0, postfix_size);
post_ptr = post_start; post_ptr = post_start;
post_end = post_start + nstate_max; post_end = post_start + nstate_max;
nfa_has_zend = FALSE; nfa_has_zend = FALSE;
@@ -347,7 +346,6 @@ realloc_post_list()
if (new_start == NULL) if (new_start == NULL)
return FAIL; return FAIL;
mch_memmove(new_start, post_start, nstate_max * sizeof(int)); mch_memmove(new_start, post_start, nstate_max * sizeof(int));
vim_memset(new_start + nstate_max, 0, 1000 * sizeof(int));
old_start = post_start; old_start = post_start;
post_start = new_start; post_start = new_start;
post_ptr = new_start + (post_ptr - old_start); post_ptr = new_start + (post_ptr - old_start);
@@ -4127,11 +4125,11 @@ nfa_regmatch(prog, start, submatch, m)
/* Allocate memory for the lists of nodes. */ /* Allocate memory for the lists of nodes. */
size = (nstate + 1) * sizeof(nfa_thread_T); size = (nstate + 1) * sizeof(nfa_thread_T);
list[0].t = (nfa_thread_T *)lalloc_clear(size, TRUE); list[0].t = (nfa_thread_T *)lalloc(size, TRUE);
list[0].len = nstate + 1; list[0].len = nstate + 1;
list[1].t = (nfa_thread_T *)lalloc_clear(size, TRUE); list[1].t = (nfa_thread_T *)lalloc(size, TRUE);
list[1].len = nstate + 1; list[1].len = nstate + 1;
list[2].t = (nfa_thread_T *)lalloc_clear(size, TRUE); list[2].t = (nfa_thread_T *)lalloc(size, TRUE);
list[2].len = nstate + 1; list[2].len = nstate + 1;
if (list[0].t == NULL || list[1].t == NULL || list[2].t == NULL) if (list[0].t == NULL || list[1].t == NULL || list[2].t == NULL)
goto theend; goto theend;
@@ -4390,7 +4388,8 @@ nfa_regmatch(prog, start, submatch, m)
/* Copy submatch info from the recursive call */ /* Copy submatch info from the recursive call */
copy_sub_off(&t->subs.norm, &m->norm); copy_sub_off(&t->subs.norm, &m->norm);
#ifdef FEAT_SYN_HL #ifdef FEAT_SYN_HL
copy_sub_off(&t->subs.synt, &m->synt); if (nfa_has_zsubexpr)
copy_sub_off(&t->subs.synt, &m->synt);
#endif #endif
/* t->state->out1 is the corresponding /* t->state->out1 is the corresponding
@@ -4441,7 +4440,8 @@ nfa_regmatch(prog, start, submatch, m)
/* Copy submatch info from the recursive call */ /* Copy submatch info from the recursive call */
copy_sub_off(&t->subs.norm, &m->norm); copy_sub_off(&t->subs.norm, &m->norm);
#ifdef FEAT_SYN_HL #ifdef FEAT_SYN_HL
copy_sub_off(&t->subs.synt, &m->synt); if (nfa_has_zsubexpr)
copy_sub_off(&t->subs.synt, &m->synt);
#endif #endif
/* Now we need to skip over the matched text and then /* Now we need to skip over the matched text and then
* continue with what follows. */ * continue with what follows. */
@@ -5053,7 +5053,8 @@ nfa_regmatch(prog, start, submatch, m)
/* Copy submatch info from the recursive call */ /* Copy submatch info from the recursive call */
copy_sub_off(&t->pim->subs.norm, &m->norm); copy_sub_off(&t->pim->subs.norm, &m->norm);
#ifdef FEAT_SYN_HL #ifdef FEAT_SYN_HL
copy_sub_off(&t->pim->subs.synt, &m->synt); if (nfa_has_zsubexpr)
copy_sub_off(&t->pim->subs.synt, &m->synt);
#endif #endif
} }
} }
@@ -5074,7 +5075,8 @@ nfa_regmatch(prog, start, submatch, m)
/* Copy submatch info from the recursive call */ /* Copy submatch info from the recursive call */
copy_sub_off(&t->subs.norm, &t->pim->subs.norm); copy_sub_off(&t->subs.norm, &t->pim->subs.norm);
#ifdef FEAT_SYN_HL #ifdef FEAT_SYN_HL
copy_sub_off(&t->subs.synt, &t->pim->subs.synt); if (nfa_has_zsubexpr)
copy_sub_off(&t->subs.synt, &t->pim->subs.synt);
#endif #endif
} }
else else
@@ -5440,7 +5442,6 @@ nfa_regcomp(expr, re_flags)
prog = (nfa_regprog_T *)lalloc(prog_size, TRUE); prog = (nfa_regprog_T *)lalloc(prog_size, TRUE);
if (prog == NULL) if (prog == NULL)
goto fail; goto fail;
vim_memset(prog, 0, prog_size);
state_ptr = prog->state; state_ptr = prog->state;
/* /*

View File

@@ -728,6 +728,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1131,
/**/ /**/
1130, 1130,
/**/ /**/