Skip to content

Use isdirectory() to check plugin directories - #1340

Merged
junegunn merged 1 commit into
junegunn:masterfrom
mattn:faster-dir-checks
Oct 5, 2026
Merged

junegunn merged 1 commit into
junegunn:masterfrom
mattn:faster-dir-checks

Conversation

@mattn

@mattn mattn commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

s:reorg_rtp() runs on every lazy load and calls globpath(dir, 'after') for all loaded plugins, and s:dobufread() calls finddir() for each candidate directory. For a single literal path both are much slower than isdirectory(), especially on Windows (finddir about 1.1 ms vs 45 us per call, globpath about 160 us vs 50 us here). The resulting runtimepath is unchanged; I checked that both versions give the same results for all 44 plugins in my config.

Vim startup on Windows with my config (median of 11 runs, VIM STARTED): 417 ms -> 378 ms. Test results are the same as on master (143/147, the same 4 failures).

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 <mattn.jp@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Fix runtimepath cleanup for comma-containing paths and duplicate separators.

Review effort: Lite
Findings: None

What changed in this PR

Improves lazy-loading performance by replacing slower directory searches with direct isdirectory() checks.

Changes:

  • Optimizes plugin after directory detection.
  • Optimizes lazy-load filetype directory checks.
File Description
plug.vim Updates runtimepath and lazy-loading directory detection.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@junegunn
junegunn merged commit 4da42e9 into junegunn:master Oct 5, 2026
1 check passed
@junegunn

junegunn commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants