Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Speed up plugin source file detection #127

Merged
merged 2 commits into from
Apr 17, 2023
Merged

feat: Speed up plugin source file detection #127

merged 2 commits into from
Apr 17, 2023

Conversation

mattmc3
Copy link
Contributor

@mattmc3 mattmc3 commented Apr 16, 2023

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.

Copy link
Contributor

@wintermi wintermi left a comment

Choose a reason for hiding this comment

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

Thanks @mattmc3

When I ran tests using zprof, I did not get the same performance improvement, though these changes simplify the code

@wintermi wintermi merged commit 8b67f66 into zap-zsh:master Apr 17, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support popular cross shell plugins like rupa/z
2 participants