don't create unnecessary tables

This commit is contained in:
leaf corcoran 2013-12-30 01:52:13 -08:00
parent 5d9ee66c14
commit 314272c376
2 changed files with 20 additions and 32 deletions

View File

@ -47,31 +47,21 @@ do
return self.name return self.name
end, end,
chain = function(self, ...) chain = function(self, ...)
local items 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({
base = self, 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, end,
index = function(self, key) index = function(self, key)
if type(key) == "string" then if type(key) == "string" then

View File

@ -18,16 +18,14 @@ class NameProxy
@name @name
chain: (...) => chain: (...) =>
items = for i in *{...} items = { base: @, ... }
if type(i) == "string" for k,v in ipairs items
{"dot", i} items[k] = if type(v) == "string"
{"dot", v}
else else
i v
build.chain { build.chain items
base: self
unpack items
}
index: (key) => index: (key) =>
if type(key) == "string" if type(key) == "string"