Originally Posted by myrroddin
If the addon uses or calls those functions a lot, like in a loop that runs hundreds or thousands of times, or if the functions are tied to event handlers that fire all the time, then creating local references will trade RAM/memory for CPU efficiency.
Lua Code:
-- psuedocode example local n = 1 do print("The value of n is: ", n) until n == 100000
print will be called 100,000 times, each one a lookup on the global table. That is not efficient.
Lua Code:
local print = print -- looked up once, and kept in memory local n = 1 do print("The value of n is: ", n) until n == 100000
|
Such a good explanation! Thank you!