f_has(): fast-path for features not in has_list[]#19550
Closed
mattn wants to merge 1 commit intovim:masterfrom
Closed
f_has(): fast-path for features not in has_list[]#19550mattn wants to merge 1 commit intovim:masterfrom
mattn wants to merge 1 commit intovim:masterfrom
Conversation
Move runtime-checked features (patch-*, vim_starting, ttyin, etc.)
before the has_list[] linear scan so that common queries like
has('patch-9.1.xxxx') skip the ~198-entry table lookup entirely.
Member
|
thanks |
zeertzjq
added a commit
to zeertzjq/neovim
that referenced
this pull request
Mar 3, 2026
…ure scan
Problem: The has() function is slow because it performs a linear scan
of the feature list for every call.
Solution: Move common runtime checks and the patch-version parser to the
beginning of the f_has() function (Yasuhiro Matsumoto).
closes: vim/vim#19550
vim/vim@327e0e3
Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
zeertzjq
added a commit
to zeertzjq/neovim
that referenced
this pull request
Mar 3, 2026
…ure scan
Problem: The has() function is slow because it performs a linear scan
of the feature list for every call.
Solution: Move common runtime checks and the patch-version parser to the
beginning of the f_has() function (Yasuhiro Matsumoto).
closes: vim/vim#19550
vim/vim@327e0e3
Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
zeertzjq
added a commit
to zeertzjq/neovim
that referenced
this pull request
Mar 3, 2026
…ure scan
Problem: The has() function is slow because it performs a linear scan
of the feature list for every call.
Solution: Move common runtime checks and the patch-version parser to the
beginning of the f_has() function (Yasuhiro Matsumoto).
closes: vim/vim#19550
vim/vim@327e0e3
Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
zeertzjq
added a commit
to neovim/neovim
that referenced
this pull request
Mar 3, 2026
…ure scan (#38135) Problem: The has() function is slow because it performs a linear scan of the feature list for every call. Solution: Move common runtime checks and the patch-version parser to the beginning of the f_has() function (Yasuhiro Matsumoto). closes: vim/vim#19550 vim/vim@327e0e3 Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
ZieMcd
pushed a commit
to ZieMcd/neovim
that referenced
this pull request
Mar 6, 2026
…ure scan (neovim#38135) Problem: The has() function is slow because it performs a linear scan of the feature list for every call. Solution: Move common runtime checks and the patch-version parser to the beginning of the f_has() function (Yasuhiro Matsumoto). closes: vim/vim#19550 vim/vim@327e0e3 Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When querying
has()for things likepatch-*,vim_starting,gui_running, etc., these were only checked after a linear scan through all ~198 entries inhas_list[]. Since none of them exist in that table, the scan always came up empty before reaching the actual check.This moves those runtime-checked features before the
has_list[]scan so we skip the unnecessary work.Called
has()1000000 times per item, averaged over 3 runs:Items that hit the fast-path are 20-28% faster. No regression for items looked up via
has_list[].