lua-users home
lua-l archive

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


How about copying the entries that you do want into a new table, then make the old table equal to the new one (leaving all that other stuff to the gc). Would that work?

new_t={a="new", b="old}
t=new_t


From: "Marcos E. Wurzius" <marcos@novanis.com.br>
Reply-To: lua-l@tecgraf.puc-rio.br
To: Multiple recipients of list <lua-l@tecgraf.puc-rio.br>
Subject: Clean the table
Date: Tue, 29 Jan 2002 16:19:51 -0400

I have a table:
t={ 1,2,3,4,...9999,10000; a="new", b="old"}

Which is the best and faster way to clean
the lfieldlist "[1]...[10000]" from the table?

I do:

for i=1,getn(t) do tremove(t,i) end

but it's very slow.

Another way:
for i=1,getn(t) do t[i]=nil end
t.n=0
This is faster.

An idea...


--
Marcos




_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.