From 6af3095d1bd5e033fe3c168155338a7e2f8f98e5 Mon Sep 17 00:00:00 2001 From: shagu Date: Sun, 17 Mar 2019 16:54:00 +0100 Subject: [PATCH] unitframes: avoid creating tables on each refresh --- api/unitframes.lua | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/api/unitframes.lua b/api/unitframes.lua index 40d0a2a7..2c2f0b44 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -1447,42 +1447,35 @@ function pfUI.uf:RefreshUnit(unit, component) end end - local color = { r = .2, g = .2, b = .2 } + local r, g, b, a = .2, .2, .2, 1 if UnitIsPlayer(unitstr) then local _, class = UnitClass(unitstr) - color = RAID_CLASS_COLORS[class] or color + if RAID_CLASS_COLORS[class] then + local color = RAID_CLASS_COLORS[class] + r, g, b = color.r, color.g, color.b + end elseif unit.label == "pet" then local happiness = GetPetHappiness() if happiness == 1 then - color = { r = 1, g = 0, b = 0 } + r, g, b = 1, 0, 0 elseif happiness == 2 then - color = { r = 1, g = 1, b = 0 } + r, g, b = 1, 1, 0 else - color = { r = 0, g = 1, b = 0 } + r, g, b = 0, 1, 0 end else - color = UnitReactionColor[UnitReaction(unitstr, "player")] or color + local color = UnitReactionColor[UnitReaction(unitstr, "player")] + r, g, b = color.r, color.g, color.b end - local r, g, b = .2, .2, .2 if C.unitframes.custom == "1" then - local cr, cg, cb, ca = pfUI.api.strsplit(",", C.unitframes.customcolor) - cr, cg, cb, ca = tonumber(cr), tonumber(cg), tonumber(cb), tonumber(ca) - unit.hp.bar:SetStatusBarColor(cr, cg, cb, ca) - if C.unitframes.pastel == "1" then - r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 - else - r, g, b = color.r, color.g, color.b - end - else - if C.unitframes.pastel == "1" then - r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 - else - r, g, b = color.r, color.g, color.b - end - unit.hp.bar:SetStatusBarColor(r, g, b) + r, g, b, a = pfUI.api.strsplit(",", C.unitframes.customcolor) + elseif C.unitframes.pastel == "1" then + r, g, b = (r + .5) * .5, (g + .5) * .5, (b + .5) * .5 end + unit.hp.bar:SetStatusBarColor(r, g, b, a) + local p = ManaBarColor[UnitPowerType(unitstr)] local pr, pg, pb = 0, 0, 0 if p then pr, pg, pb = p.r + .5, p.g +.5, p.b +.5 end