changeset 24392:79fda175df83 v8.2.2736

patch 8.2.2736: Vim9: for loop over string is a bit slow Commit: https://github.com/vim/vim/commit/175a41c13f3e27e30c662f2f418c5a347dbc645d Author: Bram Moolenaar <Bram@vim.org> Date: Thu Apr 8 18:05:03 2021 +0200 patch 8.2.2736: Vim9: for loop over string is a bit slow Problem: Vim9: for loop over string is a bit slow. Solution: Avoid using strlen().
author Bram Moolenaar <Bram@vim.org>
date Thu, 08 Apr 2021 18:15:03 +0200
parents 7d85ad2835cd
children 7383531aa41d
files src/version.c src/vim9execute.c
diffstat 2 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2736,
+/**/
     2735,
 /**/
     2734,
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -2792,12 +2792,11 @@ call_def_function(
 		    else if (ltv->v_type == VAR_STRING)
 		    {
 			char_u	*str = ltv->vval.v_string;
-			int	len = str == NULL ? 0 : (int)STRLEN(str);
 
 			// Push the next character from the string.  The index
 			// is for the last byte of the previous character.
 			++idxtv->vval.v_number;
-			if (idxtv->vval.v_number >= len)
+			if (str == NULL || str[idxtv->vval.v_number] == NUL)
 			{
 			    // past the end of the string, jump to "endfor"
 			    ectx.ec_iidx = iptr->isn_arg.forloop.for_end;