lua-users home
lua-l archive

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


How can I quickly concatenate 2 tables? (or convert a whole string to a table of bytes/numbers)

For example:

local t = {string.byte(str, 1, stack_limit)} .. {string.byte(str, stack_limit+1, stack_limit*2)} -- .. etc

Or:

local t = string.bytearray(str)

Both of them would be much faster (and human-friendly) than this:

local t1 = {string.byte(str, 1, stack_limit)}
local t2 = {string.byte(str, stack_limit+1, stack_limit*2)}
local t = t1
for k,v in ipairs(t2) do
  t[k+stack_limit] = v
end
-- etc

-- 
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.