mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
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().
This commit is contained in:
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2736,
|
||||||
/**/
|
/**/
|
||||||
2735,
|
2735,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -2792,12 +2792,11 @@ call_def_function(
|
|||||||
else if (ltv->v_type == VAR_STRING)
|
else if (ltv->v_type == VAR_STRING)
|
||||||
{
|
{
|
||||||
char_u *str = ltv->vval.v_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
|
// Push the next character from the string. The index
|
||||||
// is for the last byte of the previous character.
|
// is for the last byte of the previous character.
|
||||||
++idxtv->vval.v_number;
|
++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"
|
// past the end of the string, jump to "endfor"
|
||||||
ectx.ec_iidx = iptr->isn_arg.forloop.for_end;
|
ectx.ec_iidx = iptr->isn_arg.forloop.for_end;
|
||||||
|
Reference in New Issue
Block a user