From 4da42e9a5c948fb82970d522bd14cbab3d122ff1 Mon Sep 17 00:00:00 2001 From: mattn Date: Mon, 5 Oct 2026 00:47:24 +0000 Subject: [PATCH] Use isdirectory() to check plugin directories (#1340) finddir() and globpath() are much slower than isdirectory() for a single literal path, especially on Windows. s:reorg_rtp() runs on every lazy load and checked the after directory of all loaded plugins with globpath(). Signed-off-by: Yasuhiro Matsumoto --- plug.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plug.vim b/plug.vim index d98d611..0605bab 100644 --- a/plug.vim +++ b/plug.vim @@ -550,7 +550,7 @@ function! s:reorg_rtp() let s:middle = get(s:, 'middle', &rtp) let rtps = map(s:loaded_names(), 's:rtp(g:plugs[v:val])') - let afters = filter(map(copy(rtps), 'globpath(v:val, "after")'), '!empty(v:val)') + let afters = map(filter(copy(rtps), 'isdirectory(v:val."/after")'), 's:path(v:val."/after")') let rtp = join(map(rtps, 'escape(v:val, ",")'), ',') \ . ','.s:middle.',' \ . join(map(afters, 'escape(v:val, ",")'), ',') @@ -573,7 +573,7 @@ function! s:dobufread(names) for name in a:names let path = s:rtp(g:plugs[name]) for dir in ['ftdetect', 'ftplugin', 'after/ftdetect', 'after/ftplugin'] - if len(finddir(dir, path)) + if isdirectory(path.'/'.dir) if exists('#BufRead') doautocmd BufRead endif