patch 9.1.0037: Calling get_breakindent_win() repeatedly when computing virtcol

Commit: 
https://github.com/vim/vim/commit/5b0722b86445158f0b502ffc48a5847b0d0187bd
Author: zeertzjq <[email protected]>
Date:   Wed Jan 17 20:42:53 2024 +0100

    patch 9.1.0037: Calling get_breakindent_win() repeatedly when computing 
virtcol
    
    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 <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/charset.c b/src/charset.c
index 0e4dbbe1d..3ea2ecb8e 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -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.
diff --git a/src/structs.h b/src/structs.h
index da8c2e218..76f143305 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -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
diff --git a/src/version.c b/src/version.c
index bcc43f206..47f299756 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    37,
 /**/
     36,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1rQBqR-00HCkt-6r%40256bit.org.

Raspunde prin e-mail lui