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>
int b;
p = string;
+ if (enc_utf8 && c > 0 && c < 0x80)
+ return vim_strbyte(string, c);
if (enc_utf8 && c >= 0x80)
{
while (*p != NUL)
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)
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 310,
/**/
309,
/**/