diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-03-28 11:15:19 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-03-29 08:23:02 -0400 |
commit | 8b60368c1b9e23f0695557da170d416d71f7e6a3 (patch) | |
tree | 567daec11deb4e34e33860de8bba787a9819bfff /src/nvim/regexp_nfa.c | |
parent | aa6adacd77e59b2cf2ca7bdeae9a24c062b2a9c0 (diff) | |
download | rneovim-8b60368c1b9e23f0695557da170d416d71f7e6a3.tar.gz rneovim-8b60368c1b9e23f0695557da170d416d71f7e6a3.tar.bz2 rneovim-8b60368c1b9e23f0695557da170d416d71f7e6a3.zip |
vim-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 vim/vim#4012) Make assert_inrange() accept float values.
https://github.com/vim/vim/commit/38f08e76acf7d21bb34cf8f79f0f82eb63cdc987
Omit changes to typval_compare()
because patch v8.0.1505 was not ported.
Diffstat (limited to 'src/nvim/regexp_nfa.c')
-rw-r--r-- | src/nvim/regexp_nfa.c | 4 |
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; |