From fe0ec82edefbd077c6a66666185e468d88f3cc11 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Tue, 4 Aug 2026 22:27:43 -0500 Subject: [PATCH] Route config color strings through GetStringColor cache Replace raw strsplit(",", ...) color parsing across action bars, chat, nameplates, third-party skins, player, and roll with the cached GetStringColor / GetStringColorObject helpers, dropping the per-build string-table allocations they created. --- modules/actionbar.lua | 22 +++++++++++----------- modules/chat.lua | 14 +++++++------- modules/cooldown.lua | 10 +++++----- modules/nameplates.lua | 2 +- modules/player.lua | 2 +- modules/roll.lua | 2 +- modules/thirdparty-vanilla.lua | 12 ++++++------ modules/thirdparty.lua | 8 ++++---- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/modules/actionbar.lua b/modules/actionbar.lua index a81196c1..74537457 100644 --- a/modules/actionbar.lua +++ b/modules/actionbar.lua @@ -600,17 +600,17 @@ pfUI:RegisterModule("actionbar", function () -- update usable [out-of-range = 1, oom = 2, not-usable = 3, default = 0] if self.outofrange and C.bars.glowrange == "1" then if self.vertexstate ~= 1 then - self.icon:SetVertexColor(self.rangeColor[1], self.rangeColor[2], self.rangeColor[3], self.rangeColor[4]) + self.icon:SetVertexColor(self.rangeColor:GetRGBA()) self.vertexstate = 1 end elseif oom and C.bars.showoom == "1" then if self.vertexstate ~= 2 then - self.icon:SetVertexColor(self.oomColor[1], self.oomColor[2], self.oomColor[3], self.oomColor[4]) + self.icon:SetVertexColor(self.oomColor:GetRGBA()) self.vertexstate = 2 end elseif not usable and C.bars.showna == "1" then if self.vertexstate ~= 3 then - self.icon:SetVertexColor(self.naColor[1], self.naColor[2], self.naColor[3], self.naColor[4]) + self.icon:SetVertexColor(self.naColor:GetRGBA()) self.vertexstate = 3 end else @@ -992,13 +992,13 @@ pfUI:RegisterModule("actionbar", function () local font_offset = tonumber(C.bars.font_offset) local macro_size = tonumber(C.bars.macro_size) - local macro_color = { strsplit(",", C.bars.macro_color) } + local macro_color = { GetStringColor(C.bars.macro_color) } local count_size = tonumber(C.bars.count_size) - local count_color = { strsplit(",", C.bars.count_color) } + local count_color = { GetStringColor(C.bars.count_color) } local bind_size = tonumber(C.bars.bind_size) - local bind_color = { strsplit(",", C.bars.bind_color) } + local bind_color = { GetStringColor(C.bars.bind_color) } local cd_size = tonumber(C.bars.cd_size) @@ -1157,17 +1157,17 @@ pfUI:RegisterModule("actionbar", function () end -- range glow color - f.rangeColor = { strsplit(",", C.bars.rangecolor) } + f.rangeColor = GetStringColorObject(C.bars.rangecolor) -- out of mana color - f.oomColor = { strsplit(",", C.bars.oomcolor) } + f.oomColor = GetStringColorObject(C.bars.oomcolor) -- not usable color - f.naColor = { strsplit(",", C.bars.nacolor) } + f.naColor = GetStringColorObject(C.bars.nacolor) -- equipped color if f.equipped then - f.equipped:SetTexture(strsplit(",", C.bars.eqcolor)) + f.equipped:SetTexture(GetStringColor(C.bars.eqcolor)) end -- general appearance @@ -1546,7 +1546,7 @@ pfUI:RegisterModule("actionbar", function () -- via GetActionInfo + C_Spell.GetSpellReagents. Macro actions and -- bag-item actions are skipped (their reagent resolution would need a -- macro-body parse / item-effect lookup that we don't bother with). - local UpdateSlot = function(slot) + local function UpdateSlot(slot) local newID = nil if HasAction(slot) then local kind, spellID = GetActionInfo(slot) diff --git a/modules/chat.lua b/modules/chat.lua index c97aee0b..2db0f099 100644 --- a/modules/chat.lua +++ b/modules/chat.lua @@ -82,10 +82,10 @@ pfUI:RegisterModule("chat", function () end if C.chat.global.custombg == "1" then - local r, g, b, a = strsplit(",", C.chat.global.background) + local r, g, b, a = GetStringColor(C.chat.global.background) pfUI.chat.left.backdrop:SetBackdropColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) - local r, g, b, a = strsplit(",", C.chat.global.border) + local r, g, b, a = GetStringColor(C.chat.global.border) pfUI.chat.left.backdrop:SetBackdropBorderColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) end @@ -257,10 +257,10 @@ pfUI:RegisterModule("chat", function () end if C.chat.global.custombg == "1" then - local r, g, b, a = strsplit(",", C.chat.global.background) + local r, g, b, a = GetStringColor(C.chat.global.background) pfUI.chat.right.backdrop:SetBackdropColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) - local r, g, b, a = strsplit(",", C.chat.global.border) + local r, g, b, a = GetStringColor(C.chat.global.border) pfUI.chat.right.backdrop:SetBackdropBorderColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) end @@ -675,7 +675,7 @@ pfUI:RegisterModule("chat", function () end -- read and parse whisper color settings - local cr, cg, cb, ca = strsplit(",", C.chat.global.whisper) + local cr, cg, cb, ca = GetStringColor(C.chat.global.whisper) cr, cg, cb = tonumber(cr), tonumber(cg), tonumber(cb) local wcol = rgbhex(cr, cg, cb) @@ -706,10 +706,10 @@ pfUI:RegisterModule("chat", function () _G.CHAT_WHISPER_INFORM_GET = '[W]' .. default end - local r,g,b,a = strsplit(",", C.chat.text.timecolor) + local r,g,b,a = GetStringColor(C.chat.text.timecolor) local timecolorhex = rgbhex(r,g,b,a) - local r,g,b = strsplit(",", C.chat.text.unknowncolor) + local r,g,b = GetStringColor(C.chat.text.unknowncolor) local unknowncolorhex = rgbhex(r,g,b) -- Suppress FriendsFrame's WHO_LIST_UPDATE handling for our DLL-issued diff --git a/modules/cooldown.lua b/modules/cooldown.lua index 063beba3..62af1b5f 100644 --- a/modules/cooldown.lua +++ b/modules/cooldown.lua @@ -1,10 +1,10 @@ pfUI:RegisterModule("cooldown", function () -- cache values - local lowcolor = {strsplit(",", C.appearance.cd.lowcolor)} - local normalcolor = {strsplit(",", C.appearance.cd.normalcolor)} - local minutecolor = {strsplit(",", C.appearance.cd.minutecolor)} - local hourcolor = {strsplit(",", C.appearance.cd.hourcolor)} - local daycolor = {strsplit(",", C.appearance.cd.daycolor)} + -- local lowcolor = {strsplit(",", C.appearance.cd.lowcolor)} + -- local normalcolor = {strsplit(",", C.appearance.cd.normalcolor)} + -- local minutecolor = {strsplit(",", C.appearance.cd.minutecolor)} + -- local hourcolor = {strsplit(",", C.appearance.cd.hourcolor)} + -- local daycolor = {strsplit(",", C.appearance.cd.daycolor)} local parent, parent_name local function pfCooldownOnUpdate() diff --git a/modules/nameplates.lua b/modules/nameplates.lua index 1f6bcb21..92e75acd 100644 --- a/modules/nameplates.lua +++ b/modules/nameplates.lua @@ -948,7 +948,7 @@ nameplates:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP") -- Use the same castbar texture and color as the unit frame castbar (castbar.lua) local cbtexture = pfUI.media[C.appearance.castbar.texture] nameplate.castbar:SetStatusBarTexture(cbtexture or hptexture) - local cbr, cbg, cbb, cba = strsplit(",", C.appearance.castbar.castbarcolor) + local cbr, cbg, cbb, cba = GetStringColor(C.appearance.castbar.castbarcolor) nameplate.castbar:SetStatusBarColor(cbr, cbg, cbb, cba) -- reset endTime cache so color/texture refresh takes effect on next cast nameplate.castbar.lastEndTime = nil diff --git a/modules/player.lua b/modules/player.lua index 4b1d685e..f62e0f33 100644 --- a/modules/player.lua +++ b/modules/player.lua @@ -41,7 +41,7 @@ pfUI:RegisterModule("player", function () -- Convert "r,g,b,a" config color string to a 6-char hex string, or nil if unset local function cfgColorToHex(colorStr) if not colorStr or colorStr == "" then return nil end - local r, g, b = strsplit(",", colorStr) + local r, g, b = GetStringColor(colorStr) r, g, b = tonumber(r), tonumber(g), tonumber(b) if not r or not g or not b then return nil end return string.format("%02X%02X%02X", r * 255, g * 255, b * 255) diff --git a/modules/roll.lua b/modules/roll.lua index 7cab0d11..b3d6f886 100644 --- a/modules/roll.lua +++ b/modules/roll.lua @@ -234,7 +234,7 @@ pfUI:RegisterModule("roll", function () f.time.bar:SetAllPoints(f.time) f.time.bar:SetStatusBarTexture(pfUI.media["img:bar"]) f.time.bar:SetMinMaxValues(0, 100) - local r, g, b, a = strsplit(",", C.appearance.border.color) + local r, g, b, a = GetStringColor(C.appearance.border.color) f.time.bar:SetStatusBarColor(r, g, b) f.time.bar:SetValue(20) f.time.bar:SetScript("OnUpdate", function() diff --git a/modules/thirdparty-vanilla.lua b/modules/thirdparty-vanilla.lua index 177c5cbf..95e6de00 100644 --- a/modules/thirdparty-vanilla.lua +++ b/modules/thirdparty-vanilla.lua @@ -100,10 +100,10 @@ pfUI:RegisterModule("thirdparty-vanilla", function() CreateBackdropShadow(KLHTM_Frame) if C.thirdparty.chatbg == "1" and C.chat.global.custombg == "1" then - local r, g, b, a = strsplit(",", C.chat.global.background) + local r, g, b, a = GetStringColor(C.chat.global.background) KLHTM_Frame.backdrop:SetBackdropColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) - local r, g, b, a = strsplit(",", C.chat.global.border) + local r, g, b, a = GetStringColor(C.chat.global.border) KLHTM_Frame.backdrop:SetBackdropBorderColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) end @@ -199,10 +199,10 @@ pfUI:RegisterModule("thirdparty-vanilla", function() CreateBackdropShadow(TWTMain) if C.thirdparty.chatbg == "1" and C.chat.global.custombg == "1" then - local r, g, b, a = strsplit(",", C.chat.global.background) + local r, g, b, a = GetStringColor(C.chat.global.background) TWTMain.backdrop:SetBackdropColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) - local r, g, b, a = strsplit(",", C.chat.global.border) + local r, g, b, a = GetStringColor(C.chat.global.border) TWTMain.backdrop:SetBackdropBorderColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) end @@ -328,10 +328,10 @@ pfUI:RegisterModule("thirdparty-vanilla", function() CreateBackdropShadow(SW_BarFrame1) if C.thirdparty.chatbg == "1" and C.chat.global.custombg == "1" then - local r, g, b, a = strsplit(",", C.chat.global.background) + local r, g, b, a = GetStringColor(C.chat.global.background) SW_BarFrame1.backdrop:SetBackdropColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) - local r, g, b, a = strsplit(",", C.chat.global.border) + local r, g, b, a = GetStringColor(C.chat.global.border) SW_BarFrame1.backdrop:SetBackdropBorderColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) end diff --git a/modules/thirdparty.lua b/modules/thirdparty.lua index 4c2435f9..9b39330b 100644 --- a/modules/thirdparty.lua +++ b/modules/thirdparty.lua @@ -244,10 +244,10 @@ pfUI:RegisterModule("thirdparty", function() end if C.thirdparty.chatbg == "1" and C.chat.global.custombg == "1" then - local r, g, b, a = strsplit(",", C.chat.global.background) + local r, g, b, a = GetStringColor(C.chat.global.background) window.backdrop:SetBackdropColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) - local r, g, b, a = strsplit(",", C.chat.global.border) + local r, g, b, a = GetStringColor(C.chat.global.border) window.backdrop:SetBackdropBorderColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) end @@ -350,10 +350,10 @@ pfUI:RegisterModule("thirdparty", function() CreateBackdropShadow(frame) if C.thirdparty.chatbg == "1" and C.chat.global.custombg == "1" then - local r, g, b, a = strsplit(",", C.chat.global.background) + local r, g, b, a = GetStringColor(C.chat.global.background) frame.backdrop:SetBackdropColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) - local r, g, b, a = strsplit(",", C.chat.global.border) + local r, g, b, a = GetStringColor(C.chat.global.border) frame.backdrop:SetBackdropBorderColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) end end