0
0
mirror of https://github.com/vim/vim.git synced 2025-10-26 09:14:23 -04:00

patch 9.1.0824: too many strlen() calls in register.c

Problem:  too many strlen() calls in register.c
Solution: refactor code, add string_T struct to keep track
          of string lengths (John Marriott)

closes: #15952

Signed-off-by: John Marriott <basilisk@internode.on.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
John Marriott
2024-10-31 10:06:54 +01:00
committed by Christian Brabandt
parent a68bd6f089
commit 79f6ffd388
6 changed files with 228 additions and 140 deletions

View File

@@ -2129,7 +2129,7 @@ clip_convert_selection(char_u **str, long_u *len, Clipboard_T *cbd)
return -1;
for (i = 0; i < y_ptr->y_size; i++)
*len += (long_u)STRLEN(y_ptr->y_array[i]) + eolsize;
*len += (long_u)y_ptr->y_array[i].length + eolsize;
// Don't want newline character at end of last line if we're in MCHAR mode.
if (y_ptr->y_type == MCHAR && *len >= eolsize)
@@ -2141,9 +2141,9 @@ clip_convert_selection(char_u **str, long_u *len, Clipboard_T *cbd)
lnum = 0;
for (i = 0, j = 0; i < (int)*len; i++, j++)
{
if (y_ptr->y_array[lnum][j] == '\n')
if (y_ptr->y_array[lnum].string[j] == '\n')
p[i] = NUL;
else if (y_ptr->y_array[lnum][j] == NUL)
else if (y_ptr->y_array[lnum].string[j] == NUL)
{
# ifdef USE_CRNL
p[i++] = '\r';
@@ -2153,7 +2153,7 @@ clip_convert_selection(char_u **str, long_u *len, Clipboard_T *cbd)
j = -1;
}
else
p[i] = y_ptr->y_array[lnum][j];
p[i] = y_ptr->y_array[lnum].string[j];
}
return y_ptr->y_type;
}