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

Minor performance improvements #56

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

h3xx
Copy link

@h3xx h3xx commented Aug 26, 2023

  • Simplify setting lookup

Don't use exists("g:...") then == to lookup globals, use one get(). This is faster.

  • Don't use exec to set known variables

Setting variables using exec only makes sense if the variable name comes from the value of another variable, not how it was being used. Aside from omitting dangerous behavior (exec =~ eval), it's slightly faster.

  • Don't set &background as this can cause vim to re-load the color scheme.

According to the documentation, this causes the color scheme to be
loaded TWICE.

When a color scheme is loaded (the "g:colors_name" variable is set)
setting 'background' will cause the color scheme to be reloaded. If
the color scheme adjusts to the value of 'background' this will work.

However, if the color scheme sets 'background' itself the effect may
be undone. First delete the "g:colors_name" variable when needed.

Essentially, color schemes should not set the value of &background.

I tested these changes on vim 8.0.1453 and they appeared to work with no syntax errors, and color scheme loaded correctly.

Just glue the variables together
According to the documentation, this causes the color scheme to be
loaded TWICE.

> When a color scheme is loaded (the "g:colors_name" variable is set)
> setting 'background' will cause the color scheme to be reloaded. If
> the color scheme adjusts to the value of 'background' this will work.
>
> However, if the color scheme sets 'background' itself the effect may
> be undone. First delete the "g:colors_name" variable when needed.

Essentially, color schemes should not set the value of &background.
@h3xx h3xx changed the title Improvements Minor performance improvements Aug 26, 2023
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.

None yet

1 participant