View Single Post
01-09-18, 11:29 PM   #42
aallkkaa
A Warpwood Thunder Caller
 
aallkkaa's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2017
Posts: 98
Originally Posted by Phanx View Post
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:
  1. local AlkaT_UpdateInterval = 0.25;
  2. local AlkaT_timeSinceLastUpdate = 0;
  3. AlkaT_BMapTexts:SetScript("OnUpdate", function(self, AlkaT_elapsed)
  4.     AlkaT_timeSinceLastUpdate = AlkaT_timeSinceLastUpdate + AlkaT_elapsed;
  5.     if (AlkaT_timeSinceLastUpdate > AlkaT_UpdateInterval) then
  6.         AlkaT_SpORCo_update("player");
  7.         AlkaT_timeSinceLastUpdate = 0;
  8.     end
  9. end);
  Reply With Quote