Skip to content

Commit 28fc247

Browse files
committed
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)
1 parent 3940ec6 commit 28fc247

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/eval.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9219,23 +9219,24 @@ find_option_end(char_u **arg, int *opt_flags)
92199219
/*
92209220
* Return the autoload script name for a function or variable name.
92219221
* Returns NULL when out of memory.
9222+
* Caller must make sure that "name" contains AUTOLOAD_CHAR.
92229223
*/
92239224
char_u *
92249225
autoload_name(char_u *name)
92259226
{
9226-
char_u *p;
9227+
char_u *p, *q = NULL;
92279228
char_u *scriptname;
92289229

9229-
/* Get the script file name: replace '#' with '/', append ".vim". */
9230+
// Get the script file name: replace '#' with '/', append ".vim".
92309231
scriptname = alloc(STRLEN(name) + 14);
92319232
if (scriptname == NULL)
92329233
return FALSE;
92339234
STRCPY(scriptname, "autoload/");
92349235
STRCAT(scriptname, name);
9235-
*vim_strrchr(scriptname, AUTOLOAD_CHAR) = NUL;
9236-
STRCAT(scriptname, ".vim");
9237-
while ((p = vim_strchr(scriptname, AUTOLOAD_CHAR)) != NULL)
9236+
for (p = scriptname + 9; (p = vim_strchr(p, AUTOLOAD_CHAR)) != NULL;
9237+
q = p, ++p)
92389238
*p = '/';
9239+
STRCPY(q, ".vim");
92399240
return scriptname;
92409241
}
92419242

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,8 @@ static char *(features[]) =
777777

778778
static int included_patches[] =
779779
{ /* Add new patch number below this line */
780+
/**/
781+
1639,
780782
/**/
781783
1638,
782784
/**/

0 commit comments

Comments
 (0)