summaryrefslogtreecommitdiffstats
path: root/src/charset.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-01-17 20:42:53 +0100
committerChristian Brabandt <cb@256bit.org>2024-01-17 20:42:53 +0100
commit5b0722b86445158f0b502ffc48a5847b0d0187bd (patch)
tree4c931dbca5c39310a7fb31e1cb241f96e4a77065 /src/charset.c
parent73e16c740676e11176685ba5490eff202dc8d938 (diff)
patch 9.1.0037: Calling get_breakindent_win() repeatedly when computing virtcolv9.1.0037
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>
Diffstat (limited to 'src/charset.c')
-rw-r--r--src/charset.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/charset.c b/src/charset.c
index 0e4dbbe1dc..3ea2ecb8e2 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.