diff options
author | Lewis Russell <lewis6991@gmail.com> | 2023-07-13 10:17:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-13 10:17:19 +0100 |
commit | 516b173780e39de3ce1e4525f0a8f0ff250c992b (patch) | |
tree | afd6b0148b9a02e1e33859aa437b9348024ec5a3 /src/nvim/spell.c | |
parent | 998bebc15e9de70b3daaaa5900e974dea5abda3e (diff) | |
download | rneovim-516b173780e39de3ce1e4525f0a8f0ff250c992b.tar.gz rneovim-516b173780e39de3ce1e4525f0a8f0ff250c992b.tar.bz2 rneovim-516b173780e39de3ce1e4525f0a8f0ff250c992b.zip |
perf(rtp): reduce rtp scans (#24191)
* perf(rtp): reduce rtp scans
Problem:
Scanning the filesystem is expensive and particularly affects
startuptime.
Solution:
Reduce the amount of redundant directory scans by relying less on glob
patterns and handle vim and lua sourcing lower down.
Diffstat (limited to 'src/nvim/spell.c')
-rw-r--r-- | src/nvim/spell.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/nvim/spell.c b/src/nvim/spell.c index b337504bd9..c8a7bb2622 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -1717,23 +1717,32 @@ void slang_clear_sug(slang_T *lp) // Load one spell file and store the info into a slang_T. // Invoked through do_in_runtimepath(). -static void spell_load_cb(char *fname, void *cookie) +static bool spell_load_cb(int num_fnames, char **fnames, bool all, void *cookie) { spelload_T *slp = (spelload_T *)cookie; - slang_T *slang = spell_load_file(fname, slp->sl_lang, NULL, false); - if (slang == NULL) { - return; - } + for (int i = 0; i < num_fnames; i++) { + slang_T *slang = spell_load_file(fnames[i], slp->sl_lang, NULL, false); + + if (slang == NULL) { + continue; + } - // When a previously loaded file has NOBREAK also use it for the - // ".add" files. - if (slp->sl_nobreak && slang->sl_add) { - slang->sl_nobreak = true; - } else if (slang->sl_nobreak) { - slp->sl_nobreak = true; + // When a previously loaded file has NOBREAK also use it for the + // ".add" files. + if (slp->sl_nobreak && slang->sl_add) { + slang->sl_nobreak = true; + } else if (slang->sl_nobreak) { + slp->sl_nobreak = true; + } + + slp->sl_slang = slang; + + if (!all) { + break; + } } - slp->sl_slang = slang; + return num_fnames > 0; } /// Add a word to the hashtable of common words. |