mirror of
https://github.com/neovim/neovim.git
synced 2025-10-10 03:46:31 +00:00
vim-patch:9.1.0824: too many strlen() calls in register.c (#31022)
Problem: too many strlen() calls in register.c
Solution: refactor code, add string_T struct to keep track
of string lengths (John Marriott)
closes: vim/vim#15952
79f6ffd388
Co-authored-by: John Marriott <basilisk@internode.on.net>
This commit is contained in:
@@ -895,13 +895,13 @@ static bool is_filter_char(int c)
|
||||
return !!(tpf_flags & flag);
|
||||
}
|
||||
|
||||
void terminal_paste(int count, char **y_array, size_t y_size)
|
||||
void terminal_paste(int count, String *y_array, size_t y_size)
|
||||
{
|
||||
if (y_size == 0) {
|
||||
return;
|
||||
}
|
||||
vterm_keyboard_start_paste(curbuf->terminal->vt);
|
||||
size_t buff_len = strlen(y_array[0]);
|
||||
size_t buff_len = y_array[0].size;
|
||||
char *buff = xmalloc(buff_len);
|
||||
for (int i = 0; i < count; i++) {
|
||||
// feed the lines to the terminal
|
||||
@@ -914,13 +914,13 @@ void terminal_paste(int count, char **y_array, size_t y_size)
|
||||
terminal_send(curbuf->terminal, "\n", 1);
|
||||
#endif
|
||||
}
|
||||
size_t len = strlen(y_array[j]);
|
||||
size_t len = y_array[j].size;
|
||||
if (len > buff_len) {
|
||||
buff = xrealloc(buff, len);
|
||||
buff_len = len;
|
||||
}
|
||||
char *dst = buff;
|
||||
char *src = y_array[j];
|
||||
char *src = y_array[j].data;
|
||||
while (*src != NUL) {
|
||||
len = (size_t)utf_ptr2len(src);
|
||||
int c = utf_ptr2char(src);
|
||||
|
Reference in New Issue
Block a user