]> granicus.if.org Git - vim/commitdiff
patch 8.1.1639: changing an autoload name into a file name is inefficient v8.1.1639
authorBram Moolenaar <Bram@vim.org>
Fri, 5 Jul 2019 20:14:16 +0000 (22:14 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 5 Jul 2019 20:14:16 +0000 (22:14 +0200)
Problem:    Changing an autoload name into a script file name is inefficient.
Solution:   Remember the last replaced #. (Ozaki Kiichi, closes #4618)

src/eval.c
src/version.c

index f622b6f3fa5794446463dfbf5221b23e5f179c9a..26fad0c5facc7d2c59aa7c72e923e09278a5ffa6 100644 (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.
  * 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;
 }
 
index c835eeee551a398403f68bcf45d65f8dec8a4420..25c6076b02657301587a3a39686e6944138aefff 100644 (file)
@@ -777,6 +777,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1639,
 /**/
     1638,
 /**/