Quantcast WoWInterface - View Single Post - Check if debuff exists in game
View Single Post
08-20-14, 09:23 AM   #9
Lag123
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 4
Best place for optimising here is

Remove the
Lua Code:
  1. if not debuffList then return end
because you know that it exist
If you really want to check if the debuffList exists do that before register the event.

And localize the UnitDebuff function outside the SearchAuras function
Lua Code:
  1. local UnitDebuff = UnitDebuff

Not huge things but a small performance boost

Lua Code:
  1. local UnitDebuff = UnitDebuff
  2.  
  3. --get db via VARIABLES LOADED and saved variables
  4. local debuffList = DB.debuffList or {}
  5.  
  6. local function SearchAuras(self,event,unit)
  7.     local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId
  8.     for i=1,40 do
  9.         name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitDebuff(unit,i)
  10.         if not name then break end
  11.         if not debuffList[spellId] then
  12.           debuffList[spellid] = {name = name, rank = rank, icon = icon, debuffType = debuffType, spellId = spellId}
  13.         end
  14.     end
  15. end
  16.  
  17. local auraCheck = CreateFrame("Frame")
  18. auraCheck:SetScript("OnEvent",SearchAuras)
  19. auraCheck:RegisterEvent("UNIT_AURA")
  Reply With Quote