From 843bc1aa8d1596d8665f36b52ab0447f956016b8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 5 Mar 2026 07:54:10 +0800 Subject: [PATCH] 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 --- src/nvim/strings.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/nvim/strings.c b/src/nvim/strings.c index cc4de19d6f..d26ab90a7f 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -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--; }