To: vim_dev@googlegroups.com Subject: Patch 8.2.2736 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2736 Problem: Vim9: for loop over string is a bit slow. Solution: Avoid using strlen(). Files: src/vim9execute.c *** ../vim-8.2.2735/src/vim9execute.c 2021-04-04 20:49:46.626430253 +0200 --- src/vim9execute.c 2021-04-08 18:03:32.401252063 +0200 *************** *** 2792,2803 **** 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) { // past the end of the string, jump to "endfor" ectx.ec_iidx = iptr->isn_arg.forloop.for_end; --- 2792,2802 ---- else if (ltv->v_type == VAR_STRING) { char_u *str = ltv->vval.v_string; // Push the next character from the string. The index // is for the last byte of the previous character. ++idxtv->vval.v_number; ! 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; *** ../vim-8.2.2735/src/version.c 2021-04-07 21:58:13.203566847 +0200 --- src/version.c 2021-04-08 18:04:33.613105596 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2736, /**/ -- hundred-and-one symptoms of being an internet addict: 90. Instead of calling you to dinner, your spouse sends e-mail. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///