0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

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 #4618)
This commit is contained in:
Bram Moolenaar 2019-07-05 22:14:16 +02:00
parent 3940ec6d41
commit 28fc247f8d
2 changed files with 8 additions and 5 deletions

View File

@ -9219,23 +9219,24 @@ find_option_end(char_u **arg, int *opt_flags)
/* /*
* Return the autoload script name for a function or variable name. * Return the autoload script name for a function or variable name.
* Returns NULL when out of memory. * Returns NULL when out of memory.
* Caller must make sure that "name" contains AUTOLOAD_CHAR.
*/ */
char_u * char_u *
autoload_name(char_u *name) autoload_name(char_u *name)
{ {
char_u *p; char_u *p, *q = NULL;
char_u *scriptname; 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); scriptname = alloc(STRLEN(name) + 14);
if (scriptname == NULL) if (scriptname == NULL)
return FALSE; return FALSE;
STRCPY(scriptname, "autoload/"); STRCPY(scriptname, "autoload/");
STRCAT(scriptname, name); STRCAT(scriptname, name);
*vim_strrchr(scriptname, AUTOLOAD_CHAR) = NUL; for (p = scriptname + 9; (p = vim_strchr(p, AUTOLOAD_CHAR)) != NULL;
STRCAT(scriptname, ".vim"); q = p, ++p)
while ((p = vim_strchr(scriptname, AUTOLOAD_CHAR)) != NULL)
*p = '/'; *p = '/';
STRCPY(q, ".vim");
return scriptname; return scriptname;
} }

View File

@ -777,6 +777,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 */
/**/
1639,
/**/ /**/
1638, 1638,
/**/ /**/