]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0168: too many STRLEN() calls v9.1.0168
authorJohn Marriott <basilisk@internode.on.net>
Mon, 11 Mar 2024 21:04:45 +0000 (22:04 +0100)
committerChristian Brabandt <cb@256bit.org>
Mon, 11 Mar 2024 21:04:45 +0000 (22:04 +0100)
Problem:  too many STRLEN() calls
Solution: Make use of ml_get_len() calls instead
          (John Marriott)

closes: #14123

Signed-off-by: John Marriott <basilisk@internode.on.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/change.c
src/edit.c
src/eval.c
src/evalfunc.c
src/memline.c
src/version.c

index 3af19b600c03fa68ec98497767d87412b24d6bca..daf4faed57ed90020b6decf113f7f49d1810e191 100644 (file)
@@ -1056,7 +1056,7 @@ ins_char_bytes(char_u *buf, int charlen)
 
     col = curwin->w_cursor.col;
     oldp = ml_get(lnum);
-    linelen = (int)STRLEN(oldp) + 1;
+    linelen = (int)ml_get_len(lnum) + 1;
 
     // The lengths default to the values for when not replacing.
     oldlen = 0;
@@ -1193,7 +1193,7 @@ ins_str(char_u *s)
 
     col = curwin->w_cursor.col;
     oldp = ml_get(lnum);
-    oldlen = (int)STRLEN(oldp);
+    oldlen = (int)ml_get_len(lnum);
 
     newp = alloc(oldlen + newlen + 1);
     if (newp == NULL)
@@ -1272,7 +1272,7 @@ del_bytes(
     int                fixpos = fixpos_arg;
 
     oldp = ml_get(lnum);
-    oldlen = (int)STRLEN(oldp);
+    oldlen = (int)ml_get_len(lnum);
 
     // Can't do anything when the cursor is on the NUL after the line.
     if (col >= oldlen)
@@ -1436,12 +1436,12 @@ open_line(
 #endif
 
     // make a copy of the current line so we can mess with it
-    saved_line = vim_strsave(ml_get_curline());
+    saved_line = vim_strnsave(ml_get_curline(), ml_get_curline_len());
     if (saved_line == NULL)        // out of memory!
        return FALSE;
 
 #ifdef FEAT_PROP_POPUP
-    at_eol = curwin->w_cursor.col >= (int)STRLEN(saved_line);
+    at_eol = curwin->w_cursor.col >= (int)ml_get_curline_len();
 #endif
 
     if (State & VREPLACE_FLAG)
@@ -1454,7 +1454,7 @@ open_line(
        // the line, replacing what was there before and pushing the right
        // stuff onto the replace stack.  -- webb.
        if (curwin->w_cursor.lnum < orig_line_count)
-           next_line = vim_strsave(ml_get(curwin->w_cursor.lnum + 1));
+           next_line = vim_strnsave(ml_get(curwin->w_cursor.lnum + 1), ml_get_len(curwin->w_cursor.lnum + 1));
        else
            next_line = vim_strsave((char_u *)"");
        if (next_line == NULL)      // out of memory!
@@ -2307,7 +2307,7 @@ open_line(
     if (State & VREPLACE_FLAG)
     {
        // Put new line in p_extra
-       p_extra = vim_strsave(ml_get_curline());
+       p_extra = vim_strnsave(ml_get_curline(), ml_get_curline_len());
        if (p_extra == NULL)
            goto theend;
 
@@ -2352,7 +2352,7 @@ truncate_line(int fixpos)
        newp = vim_strsave((char_u *)"");
     else
        newp = vim_strnsave(old_line, col);
-    deleted = (int)STRLEN(old_line) - col;
+    deleted = (int)ml_get_len(lnum) - col;
 
     if (newp == NULL)
        return FAIL;
index 26853dce0194a7d179af9e3edb29122cef82d983..f700c6a12bd7ffb8da56cd3161035e0a8a15ebca 100644 (file)
@@ -4977,7 +4977,7 @@ ins_tab(void)
        {
            pos = curwin->w_cursor;
            cursor = &pos;
-           saved_line = vim_strsave(ml_get_curline());
+           saved_line = vim_strnsave(ml_get_curline(), ml_get_curline_len());
            if (saved_line == NULL)
                return FALSE;
            ptr = saved_line + pos.col;
index ca5a2685fa62d5b5227721296a98bda527fa25c1..69b837402cb03ae4726db66d04c2bead2a130943 100644 (file)
@@ -6468,7 +6468,7 @@ var2fpos(
        if (charcol)
            len = (long)mb_charlen(ml_get(pos.lnum));
        else
-           len = (long)STRLEN(ml_get(pos.lnum));
+           len = (long)ml_get_len(pos.lnum);
 
        // Get the column number
        // We accept "$" for the column number: last column.
@@ -6574,7 +6574,7 @@ var2fpos(
            if (charcol)
                pos.col = (colnr_T)mb_charlen(ml_get_curline());
            else
-               pos.col = (colnr_T)STRLEN(ml_get_curline());
+               pos.col = ml_get_curline_len();
        }
        return &pos;
     }
index eeee00d6632c6c937e00dd2182a34a57c17e4aa3..14650caf6b2ed52b7c2f41c33eb6bc475434b478 100644 (file)
@@ -3637,7 +3637,7 @@ get_col(typval_T *argvars, typval_T *rettv, int charcol)
        {
            // '> can be MAXCOL, get the length of the line then
            if (fp->lnum <= curbuf->b_ml.ml_line_count)
-               col = (colnr_T)STRLEN(ml_get(fp->lnum)) + 1;
+               col = ml_get_len(fp->lnum) + 1;
            else
                col = MAXCOL;
        }
@@ -11134,7 +11134,7 @@ f_synID(typval_T *argvars UNUSED, typval_T *rettv)
     trans = (int)tv_get_bool_chk(&argvars[2], &transerr);
 
     if (!transerr && lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count
-           && col >= 0 && col < (long)STRLEN(ml_get(lnum)))
+           && col >= 0 && col < (long)ml_get_len(lnum))
        id = syn_get_id(curwin, lnum, col, trans, NULL, FALSE);
 #endif
 
@@ -11311,7 +11311,7 @@ f_synconcealed(typval_T *argvars UNUSED, typval_T *rettv)
     if (rettv_list_alloc(rettv) == OK)
     {
        if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count
-           && col >= 0 && col <= (long)STRLEN(ml_get(lnum))
+           && col >= 0 && col <= (long)ml_get_len(lnum)
            && curwin->w_p_cole > 0)
        {
            (void)syn_get_id(curwin, lnum, col, FALSE, NULL, FALSE);
@@ -11368,7 +11368,7 @@ f_synstack(typval_T *argvars UNUSED, typval_T *rettv)
     col = (colnr_T)tv_get_number(&argvars[1]) - 1;     // -1 on type error
 
     if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count
-           && col >= 0 && col <= (long)STRLEN(ml_get(lnum))
+           && col >= 0 && col <= (long)ml_get_len(lnum)
            && rettv_list_alloc(rettv) == OK)
     {
        (void)syn_get_id(curwin, lnum, col, FALSE, NULL, TRUE);
@@ -11546,7 +11546,7 @@ f_virtcol(typval_T *argvars, typval_T *rettv)
            fp->col = 0;
        else
        {
-           len = (int)STRLEN(ml_get(fp->lnum));
+           len = (int)ml_get_len(fp->lnum);
            if (fp->col > len)
                fp->col = len;
        }
index 99b9e9f2ea9888e94a5b7be01f530c3a7e3ac5c3..5228155262123a892436dfe071b183326109f52d 100644 (file)
@@ -3661,7 +3661,7 @@ ml_replace_len(
 
     curbuf->b_ml.ml_line_ptr = line;
     curbuf->b_ml.ml_line_len = len;
-    curbuf->b_ml.ml_line_textlen = len_arg + 1;
+    curbuf->b_ml.ml_line_textlen = len_arg + !has_props;
     curbuf->b_ml.ml_line_lnum = lnum;
     curbuf->b_ml.ml_flags = (curbuf->b_ml.ml_flags | ML_LINE_DIRTY) & ~ML_EMPTY;
 
index 7279d7165d7fee1f81e709d4a6c101122c57ceb9..55c9c9fdfa35549cb97a6d74a8eeae2829a608bb 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    168,
 /**/
     167,
 /**/