summaryrefslogtreecommitdiff
path: root/Src/builtin.c
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2017-01-12 20:56:20 +0000
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2017-01-12 20:56:20 +0000
commit178e62dbfe464b56e3f12b01a159781d39b7bd85 (patch)
tree8c9b707a840eb71b69292cfc4085131b3a720eaf /Src/builtin.c
parent33799ae2b00c09445e2e47720bc740ec434416e4 (diff)
downloadzsh-178e62dbfe464b56e3f12b01a159781d39b7bd85.tar.gz
zsh-178e62dbfe464b56e3f12b01a159781d39b7bd85.zip
40342: Add directory name cache for autoload file paths.
This renders "autoload /blah/blah/*" as efficient as use of fpath.
Diffstat (limited to 'Src/builtin.c')
-rw-r--r--Src/builtin.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 716ddd429..a683032a1 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2958,13 +2958,13 @@ check_autoload(Shfunc shf, char *name, Options ops, int func)
}
}
if (getfpfunc(shf->node.nam, NULL, &dir_path, NULL, 1)) {
- zsfree(shf->filename);
+ dircache_set(&shf->filename, NULL);
if (*dir_path != '/') {
dir_path = zhtricat(metafy(zgetcwd(), -1, META_HEAPDUP),
"/", dir_path);
dir_path = xsymlink(dir_path, 1);
}
- shf->filename = ztrdup(dir_path);
+ dircache_set(&shf->filename, dir_path);
shf->node.flags |= PM_LOADDIR;
return 0;
}
@@ -3029,8 +3029,8 @@ add_autoload_function(Shfunc shf, char *funcname)
*nam++ = '\0';
dir = funcname;
}
- zsfree(shf->filename);
- shf->filename = ztrdup(dir);
+ dircache_set(&shf->filename, NULL);
+ dircache_set(&shf->filename, dir);
shf->node.flags |= PM_LOADDIR;
shfunctab->addnode(shfunctab, ztrdup(nam), shf);
} else {
@@ -3280,8 +3280,8 @@ bin_functions(char *name, char **argv, Options ops, int func)
shfunctab->addnode(shfunctab, ztrdup(funcname), shf);
}
if (*argv) {
- zsfree(shf->filename);
- shf->filename = ztrdup(*argv);
+ dircache_set(&shf->filename, NULL);
+ dircache_set(&shf->filename, *argv);
on |= PM_LOADDIR;
}
shf->node.flags = on;