1
0
forked from aniani/vim

updated for version 7.3.1149

Problem:    New regexp engine: Matching plain text could be faster.
Solution:   Detect a plain text match and handle it specifically.  Add
            vim_regfree().
This commit is contained in:
Bram Moolenaar
2013-06-08 18:19:48 +02:00
parent cd9c46265e
commit 473de61b04
28 changed files with 279 additions and 77 deletions

View File

@@ -1297,7 +1297,8 @@ skip_regexp(startp, dirc, magic, newp)
return p;
}
static regprog_T *bt_regcomp __ARGS((char_u *expr, int re_flags));
static regprog_T *bt_regcomp __ARGS((char_u *expr, int re_flags));
static void bt_regfree __ARGS((regprog_T *prog));
/*
* bt_regcomp() - compile a regular expression into internal code for the
@@ -1454,6 +1455,16 @@ bt_regcomp(expr, re_flags)
return (regprog_T *)r;
}
/*
* Free a compiled regexp program, returned by bt_regcomp().
*/
static void
bt_regfree(prog)
regprog_T *prog;
{
vim_free(prog);
}
/*
* Setup to parse the regexp. Used once to get the length and once to do it.
*/
@@ -7876,6 +7887,7 @@ reg_submatch(no)
static regengine_T bt_regengine =
{
bt_regcomp,
bt_regfree,
bt_regexec,
#if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
|| defined(FIND_REPLACE_DIALOG) || defined(PROTO)
@@ -7893,6 +7905,7 @@ static regengine_T bt_regengine =
static regengine_T nfa_regengine =
{
nfa_regcomp,
nfa_regfree,
nfa_regexec,
#if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
|| defined(FIND_REPLACE_DIALOG) || defined(PROTO)
@@ -7920,7 +7933,9 @@ static char_u regname[][30] = {
/*
* Compile a regular expression into internal code.
* Returns the program in allocated memory. Returns NULL for an error.
* Returns the program in allocated memory.
* Use vim_regfree() to free the memory.
* Returns NULL for an error.
*/
regprog_T *
vim_regcomp(expr_arg, re_flags)
@@ -7996,6 +8011,17 @@ vim_regcomp(expr_arg, re_flags)
return prog;
}
/*
* Free a compiled regexp program, returned by vim_regcomp().
*/
void
vim_regfree(prog)
regprog_T *prog;
{
if (prog != NULL)
prog->engine->regfree(prog);
}
/*
* Match a regexp against a string.
* "rmp->regprog" is a compiled regexp as returned by vim_regcomp().