[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Using unpack() twice in a single function call
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Fri, 4 Aug 2006 16:45:54 -0300
> it might be interesting to compare the speed of t[#t+1]=exp versus
> table.insert (t, exp), since it's in the inner loop a small difference could
> be significant.
If you're *really* interested in speed, try also using a local counter,
as below (untested):
-- Like unpack, but accepts multiple arguments:
function multunpack(...)
local ret = {}
local n = 0
for i = 1, select("#", ...) do
for _, rec in ipairs(select(i, ...)) do
n = n + 1
ret[n] = rec
end -- _, rec
end -- i
return unpack(ret)
end -- multunpack