diff options
author | Bram Moolenaar <Bram@vim.org> | 2013-06-08 18:19:48 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2013-06-08 18:19:48 +0200 |
commit | 473de61b0409f8f8c86585733f099f882122b280 (patch) | |
tree | 0c2b031a29a283c70d63368c38031517572d954c /src/regexp.c | |
parent | cd9c46265e4a12cf716187bc8188c7399797f806 (diff) | |
download | vim-git-473de61b0409f8f8c86585733f099f882122b280.tar.gz |
updated for version 7.3.1149v7.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().
Diffstat (limited to 'src/regexp.c')
-rw-r--r-- | src/regexp.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/regexp.c b/src/regexp.c index ae29ef53b..ef8c78db6 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -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 @@ -1455,6 +1456,16 @@ bt_regcomp(expr, re_flags) } /* + * 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. */ static void @@ -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) @@ -7997,6 +8012,17 @@ vim_regcomp(expr_arg, re_flags) } /* + * 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(). * Uses curbuf for line count and 'iskeyword'. |