diff options
author | zeertzjq <zeertzjq@outlook.com> | 2025-03-07 11:11:47 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2025-03-08 05:45:39 +0800 |
commit | af42f79221af793adeb8c2552463a87ddde08a7e (patch) | |
tree | e8220ad9173315412c7ff8be4b117e4eb3792da5 /runtime/lua/vim/_meta/api.lua | |
parent | 08d12b57ad831c56931e3a8d63072dabfbf6c5ab (diff) | |
download | rneovim-af42f79221af793adeb8c2552463a87ddde08a7e.tar.gz rneovim-af42f79221af793adeb8c2552463a87ddde08a7e.tar.bz2 rneovim-af42f79221af793adeb8c2552463a87ddde08a7e.zip |
vim-patch:partial:9.1.1179: too many strlen() calls in misc2.c
Problem: too many strlen() calls in misc2.c
Solution: refactor misc2.c and use bsearch() instead of a linear search
to find matches in the key_names_table array (John Marriott).
This commit changes misc2.c to use bsearch() to perform string searches of
the key_names_table array.
Implementation detail:
- Some entries in this array have alternate names. Add field alt_name to
point to the alternate name.
- Some entries in this array are only available if a given feature is
defined. Keep them in the array, but add a boolean field enabled to
indicate if the record can be used or not. If the feature is not
available, the corresponding enabled field is set to FALSE.
In my measurements running the test suite on a huge non-gui build on
linux, the number of string comparisons in get_special_key_code():
Before (linear search): 2,214,957
After (binary search): 297,770
A side effect of this is 1477 calls to STRLEN() in
get_special_key_name() for the same test run are no longer necessary.
closes: vim/vim#16788
https://github.com/vim/vim/commit/4a1e6dacbb2cc833353983bea7eac38191c9d3b4
Skip the mouse shape changes.
Co-authored-by: John Marriott <basilisk@internode.on.net>
Diffstat (limited to 'runtime/lua/vim/_meta/api.lua')
0 files changed, 0 insertions, 0 deletions