lua-users home
lua-l archive

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

> 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