summaryrefslogtreecommitdiff
path: root/Src/exec.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/exec.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/exec.c')
-rw-r--r--Src/exec.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 68c455b18..7a5d2bdf3 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -4902,6 +4902,7 @@ execfuncdef(Estate state, Eprog redir_prog)
shf = (Shfunc) zalloc(sizeof(*shf));
shf->funcdef = prog;
shf->node.flags = 0;
+ /* No dircache here, not a directory */
shf->filename = ztrdup(scriptfilename);
shf->lineno = lineno;
/*
@@ -4934,7 +4935,7 @@ execfuncdef(Estate state, Eprog redir_prog)
freeeprog(shf->funcdef);
if (shf->redir) /* shouldn't be */
freeeprog(shf->redir);
- zsfree(shf->filename);
+ dircache_set(&shf->filename, NULL);
zfree(shf, sizeof(*shf));
state->pc = end;
return 1;
@@ -4965,7 +4966,7 @@ execfuncdef(Estate state, Eprog redir_prog)
freeeprog(shf->funcdef);
if (shf->redir) /* shouldn't be */
freeeprog(shf->redir);
- zsfree(shf->filename);
+ dircache_set(&shf->filename, NULL);
zfree(shf, sizeof(*shf));
break;
} else {
@@ -4974,7 +4975,7 @@ execfuncdef(Estate state, Eprog redir_prog)
(signum = getsignum(s + 4)) != -1) {
if (settrap(signum, NULL, ZSIG_FUNC)) {
freeeprog(shf->funcdef);
- zsfree(shf->filename);
+ dircache_set(&shf->filename, NULL);
zfree(shf, sizeof(*shf));
state->pc = end;
return 1;
@@ -5205,7 +5206,8 @@ loadautofn(Shfunc shf, int fksh, int autol, int current_fpath)
else
shf->funcdef = dupeprog(prog, 0);
shf->node.flags &= ~(PM_UNDEFINED|PM_LOADDIR);
- zsfree(shf->filename);
+ dircache_set(&shf->filename, NULL);
+ /* Full filename, don't use dircache */
shf->filename = fname;
} else {
VARARR(char, n, strlen(shf->node.nam) + 1);
@@ -5229,7 +5231,8 @@ loadautofn(Shfunc shf, int fksh, int autol, int current_fpath)
else
shf->funcdef = dupeprog(stripkshdef(prog, shf->node.nam), 0);
shf->node.flags &= ~(PM_UNDEFINED|PM_LOADDIR);
- zsfree(shf->filename);
+ dircache_set(&shf->filename, NULL);
+ /* Full filename, don't use dircache */
shf->filename = fname;
}
popheap();
@@ -5620,6 +5623,8 @@ runshfunc(Eprog prog, FuncWrap wrap, char *name)
* Search fpath for an undefined function. Finds the file, and returns the
* list of its contents.
*
+ * If test is 0, load the function; *fname is set to zalloc'ed location.
+ *
* If test_only is 1, don't load function, just test for it:
* - Non-null return means function was found
* - *fname points to path at which found (not duplicated)