comparison src/charset.c @ 34153:c7779252fab5 v9.1.0037

patch 9.1.0037: Calling get_breakindent_win() repeatedly when computing virtcol Commit: https://github.com/vim/vim/commit/5b0722b86445158f0b502ffc48a5847b0d0187bd Author: zeertzjq <zeertzjq@outlook.com> 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 <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Wed, 17 Jan 2024 20:45:03 +0100
parents 1629cc65d78d
children 5c42c39dab38
comparison
equal deleted inserted replaced
34152:8c3b58e92292 34153:c7779252fab5
969 CLEAR_POINTER(cts); 969 CLEAR_POINTER(cts);
970 cts->cts_win = wp; 970 cts->cts_win = wp;
971 cts->cts_vcol = col; 971 cts->cts_vcol = col;
972 cts->cts_line = line; 972 cts->cts_line = line;
973 cts->cts_ptr = ptr; 973 cts->cts_ptr = ptr;
974 #ifdef FEAT_LINEBREAK
975 cts->cts_bri_size = -1;
976 #endif
974 #ifdef FEAT_PROP_POPUP 977 #ifdef FEAT_PROP_POPUP
975 if (lnum > 0 && !ignore_text_props) 978 if (lnum > 0 && !ignore_text_props)
976 { 979 {
977 char_u *prop_start; 980 char_u *prop_start;
978 int count; 981 int count;
1280 if (wcol >= width2 && width2 > 0) 1283 if (wcol >= width2 && width2 > 0)
1281 wcol %= width2; 1284 wcol %= width2;
1282 if (*sbr != NUL) 1285 if (*sbr != NUL)
1283 head_prev += vim_strsize(sbr); 1286 head_prev += vim_strsize(sbr);
1284 if (wp->w_p_bri) 1287 if (wp->w_p_bri)
1285 head_prev += get_breakindent_win(wp, line); 1288 {
1289 if (cts->cts_bri_size < 0)
1290 cts->cts_bri_size = get_breakindent_win(wp, line);
1291 head_prev += cts->cts_bri_size;
1292 }
1286 if (wcol < head_prev) 1293 if (wcol < head_prev)
1287 { 1294 {
1288 head_prev -= wcol; 1295 head_prev -= wcol;
1289 wcol += head_prev; 1296 wcol += head_prev;
1290 added += head_prev; 1297 added += head_prev;
1301 // cells taken by 'showbreak'/'breakindent' halfway current char 1308 // cells taken by 'showbreak'/'breakindent' halfway current char
1302 int head_mid = 0; 1309 int head_mid = 0;
1303 if (*sbr != NUL) 1310 if (*sbr != NUL)
1304 head_mid += vim_strsize(sbr); 1311 head_mid += vim_strsize(sbr);
1305 if (wp->w_p_bri) 1312 if (wp->w_p_bri)
1306 head_mid += get_breakindent_win(wp, line); 1313 {
1314 if (cts->cts_bri_size < 0)
1315 cts->cts_bri_size = get_breakindent_win(wp, line);
1316 head_mid += cts->cts_bri_size;
1317 }
1307 if (head_mid > 0 && wcol + size > wp->w_width) 1318 if (head_mid > 0 && wcol + size > wp->w_width)
1308 { 1319 {
1309 // Calculate effective window width. 1320 // Calculate effective window width.
1310 int prev_rem = wp->w_width - wcol; 1321 int prev_rem = wp->w_width - wcol;
1311 int width = width2 - head_mid; 1322 int width = width2 - head_mid;