Calling functions in modules performance question...

I wonder if there maybe is a performance issue when I call a function in a module. For example like this:

Runtime:addEventListener(“enterFrame”,fct.var.map.updateView)

Is the call with fct.var.map.updateView() “slow”? Regarding to for example just updateView()

or use of:

local funcis=fct.var.map.updateView()

Runtime:addEventListener(“enterFrame”,funcis)

(When accessed more than once!)

I want to be sure I will use functions in modules and nested modules correctly without any performance loss.

Any help welcome!

This only matters at the creation of the listener.

If you set a listener, the listener stores a local reference to the listener function. So it makes no difference, when the listener function is called.

But if you add the listener several times, there mighty be a difference:

local functionTable = {table1 = {table2 = {table3 = function() print(yeah) end}}} --this loop is slower, because it has to access all the tables every time for i=1, 10000 do Runtime:addEventListener("enterFrame", functionTable.table1.table2.table3) end --this loop is faster, because it uses a local reference to the function local listenerFunction = functionTable.table1.table2.table3 for i=1, 10000 do Runtime:addEventListener("enterFrame", listenerFunction) end

This only matters at the creation of the listener.

If you set a listener, the listener stores a local reference to the listener function. So it makes no difference, when the listener function is called.

But if you add the listener several times, there mighty be a difference:

local functionTable = {table1 = {table2 = {table3 = function() print(yeah) end}}} --this loop is slower, because it has to access all the tables every time for i=1, 10000 do Runtime:addEventListener("enterFrame", functionTable.table1.table2.table3) end --this loop is faster, because it uses a local reference to the function local listenerFunction = functionTable.table1.table2.table3 for i=1, 10000 do Runtime:addEventListener("enterFrame", listenerFunction) end