View Single Post
08-19-15, 12:08 PM   #27
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Rather than looping over an indexed table on every aura event, just use a hash table instead:
Code:
local bloodlust = { [2825]=1, [32182]=1, [90355]=1, [160452]=1, [80353]=1, [1459]=1 }
Then you can just do a simple table lookup inside the event handler:
Code:
if bloodlust[spellId] then
(Note that the value of each entry being 1 is irrelevant; any non-nil/false value will do. 1 is just nice and short.)

Also, looking up UnitName("player") on every aura event is pretty wasteful. Just do it once and store it in a variable outside of the event handler:
Code:
local PLAYER = UnitName("player")
...then refer to that variable in the event handler:
Code:
if (type == "SPELL_AURA_APPLIED") and (destName == PLAYER) then
__________________
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.
  Reply With Quote