mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 01:16:31 +00:00
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
8c85a2a49a
Co-authored-by: John Marriott <basilisk@internode.on.net>
This commit is contained in:
@@ -2665,16 +2665,16 @@ void ex_spellrepall(exarg_T *eap)
|
||||
const size_t repl_to_len = strlen(repl_to);
|
||||
const int addlen = (int)(repl_to_len - repl_from_len);
|
||||
|
||||
const size_t frompatlen = repl_from_len + 7;
|
||||
char *frompat = xmalloc(frompatlen);
|
||||
snprintf(frompat, frompatlen, "\\V\\<%s\\>", repl_from);
|
||||
const size_t frompatsize = repl_from_len + 7;
|
||||
char *frompat = xmalloc(frompatsize);
|
||||
size_t frompatlen = (size_t)snprintf(frompat, frompatsize, "\\V\\<%s\\>", repl_from);
|
||||
p_ws = false;
|
||||
|
||||
sub_nsubs = 0;
|
||||
sub_nlines = 0;
|
||||
curwin->w_cursor.lnum = 0;
|
||||
while (!got_int) {
|
||||
if (do_search(NULL, '/', '/', frompat, 1, SEARCH_KEEP, NULL) == 0
|
||||
if (do_search(NULL, '/', '/', frompat, frompatlen, 1, SEARCH_KEEP, NULL) == 0
|
||||
|| u_save_cursor() == FAIL) {
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user