aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/regexp_nfa.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-03-29 20:25:09 -0400
committerGitHub <noreply@github.com>2021-03-29 20:25:09 -0400
commit3c497e214f48ee1433d759f5a56c028df5186f24 (patch)
tree8256f108b6f411df484062617d733e8f1217b4af /src/nvim/regexp_nfa.c
parentaa6adacd77e59b2cf2ca7bdeae9a24c062b2a9c0 (diff)
parentaf2f0ffdf4261bf1167f044ca771fa225f2ae977 (diff)
downloadrneovim-3c497e214f48ee1433d759f5a56c028df5186f24.tar.gz
rneovim-3c497e214f48ee1433d759f5a56c028df5186f24.tar.bz2
rneovim-3c497e214f48ee1433d759f5a56c028df5186f24.zip
Merge pull request #14238 from janlazo/vim-8.1.0958
vim-patch:8.1.{874,958,989,2380},8.2.{1621,2674}
Diffstat (limited to 'src/nvim/regexp_nfa.c')
-rw-r--r--src/nvim/regexp_nfa.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index 8b5ee59d40..b6bcee3fda 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -559,7 +559,9 @@ static char_u *nfa_get_match_text(nfa_state_T *start)
*/
static void realloc_post_list(void)
{
- size_t new_max = (post_end - post_start) + 1000;
+ // For weird patterns the number of states can be very high. Increasing by
+ // 50% seems a reasonable compromise between memory use and speed.
+ const size_t new_max = (post_end - post_start) * 3 / 2;
int *new_start = xrealloc(post_start, new_max * sizeof(int));
post_ptr = new_start + (post_ptr - post_start);
post_end = new_start + new_max;