patch 9.2.0108: byteidx_common() and f_utf16idx() call ptr2len() twice

Commit: 
https://github.com/vim/vim/commit/499e93d09a9d687baafaa922660fc19dd30ffa45
Author: Yasuhiro Matsumoto <[email protected]>
Date:   Wed Mar 4 19:29:45 2026 +0000

    patch 9.2.0108: byteidx_common() and f_utf16idx() call ptr2len() twice
    
    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: #19573
    
    Signed-off-by: Yasuhiro Matsumoto <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/strings.c b/src/strings.c
index 587085099..fb14e7de6 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -1107,8 +1107,10 @@ byteidx_common(typval_T *argvars, typval_T *rettv, int 
comp)
            int c = (clen > 1) ? utf_ptr2char(t) : *t;
            if (c > 0xFFFF)
                idx--;
+           if (idx > 0)
+               t += clen;
        }
-       if (idx > 0)
+       else if (idx > 0)
            t += ptr2len(t);
     }
     rettv->vval.v_number = (varnumber_T)(t - str);
@@ -2243,7 +2245,7 @@ f_utf16idx(typval_T *argvars, typval_T *rettv)
        int c = (clen > 1) ? utf_ptr2char(p) : *p;
        if (c > 0xFFFF)
            len++;
-       p += ptr2len(p);
+       p += clen;
        if (charidx)
            idx--;
     }
diff --git a/src/version.c b/src/version.c
index 63308de4b..49a8fb313 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    108,
 /**/
     107,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1vxs9X-006qvV-Ka%40256bit.org.

Raspunde prin e-mail lui