vim-patch:9.2.0108: byteidx_common() and f_utf16idx() call ptr2len() twice (#38159)

Problem:  byteidx_common() and f_utf16idx() are calling ptr2len() twice
          per iteration, instead of reusing the already computed clen.
Solution: Reuse clen for pointer advancement in both functions
          (Yasuhiro Matsumoto).

closes: vim/vim#19573

https://github.com/vim/vim/commit/499e93d09a9d687baafaa922660fc19dd30ffa45

N/A patches:
vim-patch:9.2.0109: VIM_BACKTICK is always defined except for tiny builds

Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
This commit is contained in:
zeertzjqandYasuhiro Matsumoto authored and GitHub committed 2026-03-05 07:54:10 +08:00
1 parent 16fbde83c4
commit 843bc1aa8d
1 file changed
+5 -3
+5 -3
View File
@@ -2471,8 +2471,10 @@ static void byteidx_common(typval_T *argvars, typval_T *rettv, bool comp)
if (c > 0xFFFF) {
idx--;
}
}
if (idx > 0) {
if (idx > 0) {
t += clen;
}
} else if (idx > 0) {
t += ptr2len(t);
}
}
@@ -2996,7 +2998,7 @@ void f_utf16idx(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (c > 0xFFFF) {
len++;
}
p += ptr2len(p);
p += clen;
if (charidx) {
idx--;
}