lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Friday 04 August 2006 12:42 pm, Aaron Brown wrote:
> -- Like unpack, but accepts multiple arguments:
> function multunpack(...)
>   local ret = {}
>   for i = 1, select("#", ...) do
>     for _, rec in ipairs(select(i, ...)) do
>       ret[#ret + 1] = rec
>     end -- _, rec
>   end -- i
>   return unpack(ret)
> end -- multunpack

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.

i guess it should be the same, unless the insert() function uses a different 
way to determine the 'end' of the array.... it was a hot topic in the design 
of 5.1, i don't remember what was the final decision.

-- 
Javier

Attachment: pgpmeClICUuug.pgp
Description: PGP signature