Big List of Defold Pro Tips!

Regarding optimizations (but rather micro-optimizations) it is good to localize as much as possible. I saw in some Lua libraries localized versions of used globals and this is pretty clever, especially when it comes to some commonly used ones or ones used in update() functions!

local table_insert = table.insert
local table_remove = table.remove

or even only table:

local table = table
local pairs, ipairs, print = pairs, ipairs, print

for i,v in pairs(some_table) do
   table.insert(i)
   print(v)
end

etc.
So when you actually overwrite the global with your local, you don’t need to change each call in your code then :wink:

4 Likes