aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_getln.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-05-21 06:22:23 +0800
committerzeertzjq <zeertzjq@outlook.com>2024-05-22 06:37:26 +0800
commitb86381f425223adf0ff91fa0746914a5774ddabb (patch)
tree3a954980956a6ac250fc2e1a875802d5057bddde /src/nvim/ex_getln.c
parent879d17ea8d62c199ea0c91c5f37a4f25495be7ce (diff)
downloadrneovim-b86381f425223adf0ff91fa0746914a5774ddabb.tar.gz
rneovim-b86381f425223adf0ff91fa0746914a5774ddabb.tar.bz2
rneovim-b86381f425223adf0ff91fa0746914a5774ddabb.zip
vim-patch:9.1.0426: too many strlen() calls in search.c
Problem: too many strlen() calls in search.c Solution: refactor code and remove more strlen() calls, use explicit variable to remember strlen (John Marriott) closes: vim/vim#14796 https://github.com/vim/vim/commit/8c85a2a49acf80e4f53ec51e6ff2a5f3830eeddb Co-authored-by: John Marriott <basilisk@internode.on.net>
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r--src/nvim/ex_getln.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 8c9e6e454a..f18dc0f747 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -470,7 +470,7 @@ static void may_do_incsearch_highlighting(int firstc, int count, incsearch_state
.sa_tm = &tm,
};
found = do_search(NULL, firstc == ':' ? '/' : firstc, search_delim,
- ccline.cmdbuff + skiplen, count,
+ ccline.cmdbuff + skiplen, (size_t)patlen, count,
search_flags, &sia);
ccline.cmdbuff[skiplen + patlen] = next_char;
emsg_off--;
@@ -884,11 +884,12 @@ static uint8_t *command_line_enter(int firstc, int count, int indent, bool clear
&& ccline.cmdlen
&& s->firstc != NUL
&& (s->some_key_typed || s->histype == HIST_SEARCH)) {
- add_to_history(s->histype, ccline.cmdbuff, true,
+ size_t cmdbufflen = strlen(ccline.cmdbuff);
+ add_to_history(s->histype, ccline.cmdbuff, cmdbufflen, true,
s->histype == HIST_SEARCH ? s->firstc : NUL);
if (s->firstc == ':') {
xfree(new_last_cmdline);
- new_last_cmdline = xstrdup(ccline.cmdbuff);
+ new_last_cmdline = xstrnsave(ccline.cmdbuff, cmdbufflen);
}
}
@@ -1451,7 +1452,7 @@ static int may_do_command_line_next_incsearch(int firstc, int count, incsearch_s
pat[patlen] = NUL;
int found = searchit(curwin, curbuf, &t, NULL,
next_match ? FORWARD : BACKWARD,
- pat, count, search_flags,
+ pat, (size_t)patlen, count, search_flags,
RE_SEARCH, NULL);
emsg_off--;
pat[patlen] = save;