summaryrefslogtreecommitdiff
path: root/src/eval.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-07-05 22:14:16 +0200
committerBram Moolenaar <Bram@vim.org>2019-07-05 22:14:16 +0200
commit28fc247f8d94a1cfabbcf2691ca942bde96f6d2f (patch)
tree54836cfabdef5fd1dd3e9f128307e0b0869f13c7 /src/eval.c
parent3940ec6d41a07f9abbfba7d4db6b49d3d8b43a9a (diff)
downloadvim-git-28fc247f8d94a1cfabbcf2691ca942bde96f6d2f.tar.gz
patch 8.1.1639: changing an autoload name into a file name is inefficientv8.1.1639
Problem: Changing an autoload name into a script file name is inefficient. Solution: Remember the last replaced #. (Ozaki Kiichi, closes #4618)
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/eval.c b/src/eval.c
index f622b6f3f..26fad0c5f 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -9219,23 +9219,24 @@ find_option_end(char_u **arg, int *opt_flags)
/*
* 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;
}