diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-02-20 22:04:32 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-02-20 22:04:32 +0100 |
commit | 38f08e76acf7d21bb34cf8f79f0f82eb63cdc987 (patch) | |
tree | aa303c467edd65762eb39e19843d8112f035f164 /src/regexp_nfa.c | |
parent | 35856718881834a76225530d502c68fdec6584cf (diff) | |
download | vim-git-38f08e76acf7d21bb34cf8f79f0f82eb63cdc987.tar.gz |
patch 8.1.0958: compiling weird regexp pattern is very slowv8.1.0958
Problem: Compiling weird regexp pattern is very slow.
Solution: When reallocating post list increase size by 50%. (Kuang-che Wu,
closes #4012) Make assert_inrange() accept float values.
Diffstat (limited to 'src/regexp_nfa.c')
-rw-r--r-- | src/regexp_nfa.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index 9633791bc..333c006f4 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -509,10 +509,13 @@ nfa_get_match_text(nfa_state_T *start) realloc_post_list(void) { int nstate_max = (int)(post_end - post_start); - int new_max = nstate_max + 1000; + int new_max; int *new_start; int *old_start; + // For weird patterns the number of states can be very high. Increasing by + // 50% seems a reasonable compromise between memory use and speed. + new_max = nstate_max * 3 / 2; new_start = (int *)lalloc(new_max * sizeof(int), TRUE); if (new_start == NULL) return FAIL; |