mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
patch 9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()
Problem: More code can use ml_get_buf_len() instead of STRLEN(). Solution: Change more STRLEN() calls to ml_get_buf_len(). Also do not set ml_line_textlen in ml_replace_len() if "has_props" is set, because "len_arg" also includes the size of text properties in that case. (zeertzjq) closes: #14183 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
5cac1a9bee
commit
94b7c3233e
@@ -932,7 +932,7 @@ nb_partialremove(linenr_T lnum, colnr_T first, colnr_T last)
|
||||
int lastbyte = last;
|
||||
|
||||
oldtext = ml_get(lnum);
|
||||
oldlen = (int)STRLEN(oldtext);
|
||||
oldlen = ml_get_len(lnum);
|
||||
if (first >= (colnr_T)oldlen || oldlen == 0) // just in case
|
||||
return;
|
||||
if (lastbyte >= oldlen)
|
||||
@@ -957,8 +957,8 @@ nb_joinlines(linenr_T first, linenr_T other)
|
||||
int len_first, len_other;
|
||||
char_u *p;
|
||||
|
||||
len_first = (int)STRLEN(ml_get(first));
|
||||
len_other = (int)STRLEN(ml_get(other));
|
||||
len_first = ml_get_len(first);
|
||||
len_other = ml_get_len(other);
|
||||
p = alloc(len_first + len_other + 1);
|
||||
if (p == NULL)
|
||||
return;
|
||||
@@ -1402,7 +1402,7 @@ nb_do_cmd(
|
||||
int col = pos == NULL ? 0 : pos->col;
|
||||
|
||||
// Insert halfway a line.
|
||||
newline = alloc(STRLEN(oldline) + len + 1);
|
||||
newline = alloc(ml_get_len(lnum) + len + 1);
|
||||
if (newline != NULL)
|
||||
{
|
||||
mch_memmove(newline, oldline, (size_t)col);
|
||||
@@ -3314,8 +3314,7 @@ get_buf_size(buf_T *bufp)
|
||||
eol_size = 1;
|
||||
for (lnum = 1; lnum <= bufp->b_ml.ml_line_count; ++lnum)
|
||||
{
|
||||
char_count += (long)STRLEN(ml_get_buf(bufp, lnum, FALSE))
|
||||
+ eol_size;
|
||||
char_count += ml_get_buf_len(bufp, lnum) + eol_size;
|
||||
// Check for a CTRL-C every 100000 characters
|
||||
if (char_count > last_check)
|
||||
{
|
||||
|
Reference in New Issue
Block a user