diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-01-22 10:00:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-22 10:00:11 +0800 |
commit | 8c6de9147cabbf99d18afbdbed2f11f30c1d0dfc (patch) | |
tree | b05e873236f53b2b9dc244c00f538eb47f45ab2f /src/nvim/getchar.c | |
parent | a25aeee856e2fb02f93ffa5c2e5d43fd75ead2cf (diff) | |
parent | fd08de4b85ae42fe3ad5b480b58df9f7fff76269 (diff) | |
download | rneovim-8c6de9147cabbf99d18afbdbed2f11f30c1d0dfc.tar.gz rneovim-8c6de9147cabbf99d18afbdbed2f11f30c1d0dfc.tar.bz2 rneovim-8c6de9147cabbf99d18afbdbed2f11f30c1d0dfc.zip |
Merge pull request #26813 from VanaIgr/screen-pos-speedup
perf: make screen size and position calculations more efficient
N/A patches for version.c:
vim-patch:9.1.0037: Calling get_breakindent_win() repeatedly when computing virtcol
vim-patch:9.1.0038: Unnecessary loop in getvcol()
Diffstat (limited to 'src/nvim/getchar.c')
-rw-r--r-- | src/nvim/getchar.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 23937a6bb5..6515cc84da 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -2502,20 +2502,22 @@ static int vgetorpeek(bool advance) // we are expecting to truncate the trailing // white-space, so find the last non-white // character -- webb - if (did_ai - && *skipwhite(get_cursor_line_ptr() + curwin->w_cursor.col) == NUL) { + if (did_ai && *skipwhite(get_cursor_line_ptr() + curwin->w_cursor.col) == NUL) { curwin->w_wcol = 0; ptr = get_cursor_line_ptr(); - chartabsize_T cts; - init_chartabsize_arg(&cts, curwin, curwin->w_cursor.lnum, 0, ptr, ptr); - while (cts.cts_ptr < ptr + curwin->w_cursor.col) { - if (!ascii_iswhite(*cts.cts_ptr)) { - curwin->w_wcol = cts.cts_vcol; + char *endptr = ptr + curwin->w_cursor.col; + + CharsizeArg arg; + CSType cstype = init_charsize_arg(&arg, curwin, curwin->w_cursor.lnum, ptr); + StrCharInfo ci = utf_ptr2StrCharInfo(ptr); + int vcol = 0; + while (ci.ptr < endptr) { + if (!ascii_iswhite(ci.chr.value)) { + curwin->w_wcol = vcol; } - cts.cts_vcol += lbr_chartabsize(&cts); - cts.cts_ptr += utfc_ptr2len(cts.cts_ptr); + vcol += win_charsize(cstype, vcol, ci.ptr, ci.chr.value, &arg).width; + ci = utfc_next(ci); } - clear_chartabsize_arg(&cts); curwin->w_wrow = curwin->w_cline_row + curwin->w_wcol / curwin->w_width_inner; |