module refactoring
This commit is contained in:
+7
-10
@@ -1,5 +1,4 @@
|
||||
if defined 'T' then return end
|
||||
module 'T'
|
||||
if module 'T' then return end
|
||||
|
||||
local next, getn, setn, tremove, setmetatable = next, getn, table.setn, tremove, setmetatable
|
||||
|
||||
@@ -56,17 +55,15 @@ do
|
||||
M.static = setmetatable({}, {__metatable=false, __newindex=nop, __call=f, __sub=f})
|
||||
end
|
||||
|
||||
M.get.T = acquire
|
||||
|
||||
do
|
||||
local function ret(t)
|
||||
local function unpack(t)
|
||||
if getn(t) > 0 then
|
||||
return tremove(t, 1), ret(t)
|
||||
return tremove(t, 1), unpack(t)
|
||||
else
|
||||
release(t)
|
||||
end
|
||||
end
|
||||
M.ret = ret
|
||||
M.unpack = unpack
|
||||
end
|
||||
|
||||
M.empty = setmetatable({}, {__metatable=false, __newindex=nop})
|
||||
@@ -118,18 +115,18 @@ do
|
||||
})
|
||||
end
|
||||
|
||||
M.A = vararg(function(arg)
|
||||
M.list = vararg(function(arg)
|
||||
auto_release[arg] = nil
|
||||
return arg
|
||||
end)
|
||||
M.S = vararg(function(arg)
|
||||
M.set = vararg(function(arg)
|
||||
local t = acquire()
|
||||
for _, v in pairs(arg) do
|
||||
t[v] = true
|
||||
end
|
||||
return t
|
||||
end)
|
||||
M.O = vararg(function(arg)
|
||||
M.map = vararg(function(arg)
|
||||
local t = acquire()
|
||||
for i = 1, getn(arg), 2 do
|
||||
t[arg[i]] = arg[i + 1]
|
||||
|
||||
Reference in New Issue
Block a user