Skip to content

Commit

Permalink
modns: nsauto.lua: [*] switch to using subloader for mk_parent_ns() t…
Browse files Browse the repository at this point in the history
…o deduplicate redundant logic
  • Loading branch information
thetaepsilon committed Sep 30, 2018
1 parent bd506c0 commit 69de783
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions modns/nsauto.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 69de783

Please sign in to comment.