]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0037: Calling get_breakindent_win() repeatedly when computing virtcol v9.1.0037
authorzeertzjq <zeertzjq@outlook.com>
Wed, 17 Jan 2024 19:42:53 +0000 (20:42 +0100)
committerChristian Brabandt <cb@256bit.org>
Wed, 17 Jan 2024 19:42:53 +0000 (20:42 +0100)
Problem:  Calling get_breakindent_win() repeatedly when computing
          virtual column, and get_breakindent_win() does a STRCMP() on
          the whole line since patch 9.0.0016.
Solution: Cache the result, since the line doesn't change.
          (zeertzjq)

closes: #13879

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/charset.c
src/structs.h
src/version.c

index 0e4dbbe1dca99a76bb347863a4ccdd1265a40152..3ea2ecb8e216c2f2c7f7c293f0b51a992b854363 100644 (file)
@@ -971,6 +971,9 @@ init_chartabsize_arg(
     cts->cts_vcol = col;
     cts->cts_line = line;
     cts->cts_ptr = ptr;
+#ifdef FEAT_LINEBREAK
+    cts->cts_bri_size = -1;
+#endif
 #ifdef FEAT_PROP_POPUP
     if (lnum > 0 && !ignore_text_props)
     {
@@ -1282,7 +1285,11 @@ win_lbr_chartabsize(
            if (*sbr != NUL)
                head_prev += vim_strsize(sbr);
            if (wp->w_p_bri)
-               head_prev += get_breakindent_win(wp, line);
+           {
+               if (cts->cts_bri_size < 0)
+                   cts->cts_bri_size = get_breakindent_win(wp, line);
+               head_prev += cts->cts_bri_size;
+           }
            if (wcol < head_prev)
            {
                head_prev -= wcol;
@@ -1303,7 +1310,11 @@ win_lbr_chartabsize(
            if (*sbr != NUL)
                head_mid += vim_strsize(sbr);
            if (wp->w_p_bri)
-               head_mid += get_breakindent_win(wp, line);
+           {
+               if (cts->cts_bri_size < 0)
+                   cts->cts_bri_size = get_breakindent_win(wp, line);
+               head_mid += cts->cts_bri_size;
+           }
            if (head_mid > 0 && wcol + size > wp->w_width)
            {
                // Calculate effective window width.
index da8c2e218ec984087015303f20839787d813d5df..76f143305b755e4f80d09aafba19ef50fa0d17b1 100644 (file)
@@ -4909,6 +4909,10 @@ typedef struct {
     win_T      *cts_win;
     char_u     *cts_line;              // start of the line
     char_u     *cts_ptr;               // current position in line
+#ifdef FEAT_LINEBREAK
+    int                cts_bri_size;           // cached size of 'breakindent', or -1
+                                       // if not computed yet
+#endif
 #ifdef FEAT_PROP_POPUP
     int                cts_text_prop_count;    // number of text props; when zero
                                        // cts_text_props is not used
index bcc43f2068516a54be07cc5c401fada6ada1f916..47f2997563f26d796eb8b2a05a42024c31e308f8 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    37,
 /**/
     36,
 /**/