feat: Speed up plugin source file detection #127
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
try_source
function could use some optimization. The current implementation profiles this way:num calls time self name ----------------------------------------------------------------------------------- 1) 2 27.07 13.53 34.68% 27.07 13.53 34.68% compaudit 2) 9 32.95 3.66 42.22% 23.51 2.61 30.12% _try_source 3) 1 40.43 40.43 51.81% 13.37 13.37 17.13% compinit
Using NULLGLOB pattern matching to populate a list of possible plugin init files and taking the first element of that list both simplifies the function, and also makes it faster.
num calls time self name ----------------------------------------------------------------------------------- 1) 2 27.29 13.64 39.04% 27.29 13.64 39.04% compaudit 2) 9 24.43 2.71 34.96% 14.20 1.58 20.32% _new_try_source 3) 1 40.83 40.83 58.42% 13.54 13.54 19.38% compinit
If you are okay with this kind of advanced pattern matching, this PR also fixes #125 and supreceeds #126.