Best place for optimising here is
Remove the
Lua Code:
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:
local UnitDebuff = UnitDebuff
Not huge things but a small performance boost
Lua Code:
local UnitDebuff = UnitDebuff
--get db via VARIABLES LOADED and saved variables
local debuffList = DB.debuffList or {}
local function SearchAuras(self,event,unit)
local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId
for i=1,40 do
name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitDebuff(unit,i)
if not name then break end
if not debuffList[spellId] then
debuffList[spellid] = {name = name, rank = rank, icon = icon, debuffType = debuffType, spellId = spellId}
end
end
end
local auraCheck = CreateFrame("Frame")
auraCheck:SetScript("OnEvent",SearchAuras)
auraCheck:RegisterEvent("UNIT_AURA")