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.
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c
index 9633791..333c006 100644
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -509,10 +509,13 @@
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;