Originally Posted by Phanx
2. Upvalue any globals you're reading in frequently called functions, like OnUpdate, CLEU, UNIT_AURA, etc. Don't bother upvaluing globals you only read infrequently, such as in response to the user changing an option, the player leaving combat, etc.
|
Regarding the OnUpdate functions, I presume you mean globals you would call each time OnUpdate is run, right?
I mean, in the example bellow (from a non publshed little addon of mine), the function AlkaT_SpORCo_update() is called only once every 0.25 seconds, and it is in this function that I call two global functions. If I understood correctly, upvalueing these two functions would bring no benefit at all, right?
Lua Code:
local AlkaT_UpdateInterval = 0.25;
local AlkaT_timeSinceLastUpdate = 0;
AlkaT_BMapTexts:SetScript("OnUpdate", function(self, AlkaT_elapsed)
AlkaT_timeSinceLastUpdate = AlkaT_timeSinceLastUpdate + AlkaT_elapsed;
if (AlkaT_timeSinceLastUpdate > AlkaT_UpdateInterval) then
AlkaT_SpORCo_update("player");
AlkaT_timeSinceLastUpdate = 0;
end
end);