lua-users home
lua-l archive

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

Is there an efficient way to copy Lua tables?

I've written the code which iterates the source table and adds the values to
the destination table and copies the metatable, but this all seems
relatively inefficient relative to explicitly saying "duplicate the
underlying data structures".

Is there a function that I've just missed?

(I've seen the lazy copy examples. That's vulnerable to having the source
table change out from under it. It also keeps alive references to all of the
data in the source table.)