From 69de7834b1316de866389af34593055c78bb7e6d Mon Sep 17 00:00:00 2001 From: thetaepsilon Date: Sun, 30 Sep 2018 15:55:25 +0100 Subject: [PATCH] modns: nsauto.lua: [*] switch to using subloader for mk_parent_ns() to deduplicate redundant logic --- modns/nsauto.lua | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/modns/nsauto.lua b/modns/nsauto.lua index bd97f07..40700a8 100644 --- a/modns/nsauto.lua +++ b/modns/nsauto.lua @@ -11,22 +11,18 @@ local get_child_subloader = (dofile(p))(loader, create_subloader) local dname = "mk_parent_ns_noauto() " -local mk_parent_ns_noauto_inner = function(list, base, sep) +local mk_parent_ns_noauto_inner = function(list, subloader) local result = {} for _, sub in ipairs(list) do - local subpath = base..sep..sub - result[sub] = loader:get(subpath) + result[sub] = subloader(sub) end return result end local dname = "mk_parent_ns() " local mk_parent_ns = function(list) - local inflight, ptype = loader:get_current_inflight() - if not inflight then error(dname.."must be invoked via dynamic loading of another file") end - local sep = ptype.pathsep - if not sep then error(dname.."auto path deduction failure: path type "..ptype.label.." doesn't support separator concatenation") end - return mk_parent_ns_noauto_inner(list, inflight, sep) + local subloader = get_child_subloader() + return mk_parent_ns_noauto_inner(list, subloader) end return {