# HG changeset patch # User Bram Moolenaar # Date 1562357704 -7200 # Node ID 306a51f4c7310613c696a3893d1954e62630ffbb # Parent ccddc705acef4f87aa6cd2bda26e0c9aa8b5248d patch 8.1.1639: changing an autoload name into a file name is inefficient commit https://github.com/vim/vim/commit/28fc247f8d94a1cfabbcf2691ca942bde96f6d2f Author: Bram Moolenaar Date: Fri Jul 5 22:14:16 2019 +0200 patch 8.1.1639: changing an autoload name into a file name is inefficient Problem: Changing an autoload name into a script file name is inefficient. Solution: Remember the last replaced #. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/4618) diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -9219,23 +9219,24 @@ find_option_end(char_u **arg, int *opt_f /* * Return the autoload script name for a function or variable name. * Returns NULL when out of memory. + * Caller must make sure that "name" contains AUTOLOAD_CHAR. */ char_u * autoload_name(char_u *name) { - char_u *p; + char_u *p, *q = NULL; char_u *scriptname; - /* Get the script file name: replace '#' with '/', append ".vim". */ + // Get the script file name: replace '#' with '/', append ".vim". scriptname = alloc(STRLEN(name) + 14); if (scriptname == NULL) return FALSE; STRCPY(scriptname, "autoload/"); STRCAT(scriptname, name); - *vim_strrchr(scriptname, AUTOLOAD_CHAR) = NUL; - STRCAT(scriptname, ".vim"); - while ((p = vim_strchr(scriptname, AUTOLOAD_CHAR)) != NULL) + for (p = scriptname + 9; (p = vim_strchr(p, AUTOLOAD_CHAR)) != NULL; + q = p, ++p) *p = '/'; + STRCPY(q, ".vim"); return scriptname; } diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -778,6 +778,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1639, +/**/ 1638, /**/ 1637,