mirror of
https://github.com/vim/vim.git
synced 2026-05-28 00:21:37 +02:00
patch 9.2.0310: unnecessary work in vim_strchr() and find_term_bykeys()
problem: unnecessary work in vim_strchr() and find_term_bykeys()
Solution: Redirect vim_strchr() to vim_strbyte() for ASCII input
Add an early exit to find_term_bykeys() using the terminal
leader table, mirroring check_termcode(). Reduces instruction
count on startup by about 27%. (Yasuhiro Matsumoto)
closes: #19902
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
4368ad34df
commit
f9981bbc8e
@@ -626,6 +626,8 @@ vim_strchr(char_u *string, int c)
|
||||
int b;
|
||||
|
||||
p = string;
|
||||
if (enc_utf8 && c > 0 && c < 0x80)
|
||||
return vim_strbyte(string, c);
|
||||
if (enc_utf8 && c >= 0x80)
|
||||
{
|
||||
while (*p != NUL)
|
||||
|
||||
@@ -7209,6 +7209,13 @@ find_term_bykeys(char_u *src, int *matchlen)
|
||||
int slen, modslen;
|
||||
int thislen;
|
||||
|
||||
// Most input bytes cannot start a terminal code. Reuse the same leader
|
||||
// table as check_termcode() to avoid scanning termcodes[] unnecessarily.
|
||||
if (need_gather)
|
||||
gather_termleader();
|
||||
if (*src == NUL || vim_strchr(termleader, *src) == NULL)
|
||||
return -1;
|
||||
|
||||
// find longest match
|
||||
// borrows part of check_termcode
|
||||
for (i = 0; i < tc_len; ++i)
|
||||
|
||||
@@ -734,6 +734,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
310,
|
||||
/**/
|
||||
309,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user