mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
don't create unnecessary tables
This commit is contained in:
parent
5d9ee66c14
commit
314272c376
@ -47,31 +47,21 @@ do
|
||||
return self.name
|
||||
end,
|
||||
chain = function(self, ...)
|
||||
local items
|
||||
do
|
||||
local _accum_0 = { }
|
||||
local _len_0 = 1
|
||||
local _list_0 = {
|
||||
...
|
||||
}
|
||||
for _index_0 = 1, #_list_0 do
|
||||
local i = _list_0[_index_0]
|
||||
if type(i) == "string" then
|
||||
_accum_0[_len_0] = {
|
||||
"dot",
|
||||
i
|
||||
}
|
||||
else
|
||||
_accum_0[_len_0] = i
|
||||
end
|
||||
_len_0 = _len_0 + 1
|
||||
end
|
||||
items = _accum_0
|
||||
end
|
||||
return build.chain({
|
||||
local items = {
|
||||
base = self,
|
||||
unpack(items)
|
||||
})
|
||||
...
|
||||
}
|
||||
for k, v in ipairs(items) do
|
||||
if type(v) == "string" then
|
||||
items[k] = {
|
||||
"dot",
|
||||
v
|
||||
}
|
||||
else
|
||||
items[k] = v
|
||||
end
|
||||
end
|
||||
return build.chain(items)
|
||||
end,
|
||||
index = function(self, key)
|
||||
if type(key) == "string" then
|
||||
|
@ -18,16 +18,14 @@ class NameProxy
|
||||
@name
|
||||
|
||||
chain: (...) =>
|
||||
items = for i in *{...}
|
||||
if type(i) == "string"
|
||||
{"dot", i}
|
||||
items = { base: @, ... }
|
||||
for k,v in ipairs items
|
||||
items[k] = if type(v) == "string"
|
||||
{"dot", v}
|
||||
else
|
||||
i
|
||||
v
|
||||
|
||||
build.chain {
|
||||
base: self
|
||||
unpack items
|
||||
}
|
||||
build.chain items
|
||||
|
||||
index: (key) =>
|
||||
if type(key) == "string"
|
||||
|
Loading…
Reference in New Issue
Block a user