Mercurial > vim
changeset 17280:306a51f4c731 v8.1.1639
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 <Bram@vim.org>
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 05 Jul 2019 22:15:04 +0200 |
parents | ccddc705acef |
children | 0f11ef19b3d3 |
files | src/eval.c src/version.c |
diffstat | 2 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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; }