@davebollinger @ roaminggamer
The second one is definetly faster (but not by much).
LUA tables are hashed in relation to there entries. (0 entries, 1 entry, 2 entries, 4 etries, 8 entries, 16 entries etc.)
Each time a LUA table exeeds there current hash maximum the whole table is rehashed to the next power of two.
(e.g. a table has 8 entries and a ninth is inserted, so the table is rehashed to 16 entries)
Rehashing takes processing time, so fewer rehashes are more efficient.
So it is faster to insert elements directly into a table at its creation than afterwards.
@espace3d
You only need to localize the value i you want to use it later on. (so you do not need to acces the table again.
As I stated above, inserting values at a tables creation is faster. So if possible use one of the following the following:
local t = { head = display.newCircle(10,10,10), }
local head = display.newCircle(10,10,10) local t = { head = head }
Greetings
Torben 