0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.1.0958: compiling weird regexp pattern is very slow

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.
This commit is contained in:
Bram Moolenaar
2019-02-20 22:04:32 +01:00
parent 3585671888
commit 38f08e76ac
5 changed files with 84 additions and 25 deletions

View File

@@ -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;