From 178e62dbfe464b56e3f12b01a159781d39b7bd85 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Thu, 12 Jan 2017 20:56:20 +0000
Subject: 40342: Add directory name cache for autoload file paths.
This renders "autoload /blah/blah/*" as efficient as use of
fpath.
---
Src/builtin.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
(limited to 'Src/builtin.c')
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;
--
cgit v1.2.3