View Single Post
03-17-13, 12:51 AM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Clamsoda View Post
Edit: In response to Torhal's suggestion of not using select(), should I just upsource the select() function, or use something similar to: <code>
If those are the only options, then you'd use the code you posted. Calling functions is sloooooow, even if they're upvalued.

However, since your code is only handling one event, you can just name the arguments as they're passed to your handler:

Code:
frame:SetScript("OnEvent", function(self, event, timestamp, combatEvent, _, sourceGUID, _, _, _, destGUID, _, _, _, amount)
     if combatEvent == "SWING_DAMAGE" and destGUID == PLAYER_GUID and knownTypes[tonumber(strsub(sourceGUID, 5, 5), 16) % 8] == "NPC" then
          damageTable[time()] = amount
     end
end)
On a side note, strsub(<string>, 5, 5) is faster than <string>:sub(5, 5) even if you don't upvalue strsub, and way faster if you do.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 03-17-13 at 12:58 AM.
  Reply With Quote