Collapse frameState.hasTarget into targetGuid

hasTarget was always snapshotted alongside targetGuid (UnitExists("target")
next to UnitGUID("target")), so it was just targetGuid ~= nil. Drop the
field and derive it from targetGuid at both read sites; remove the now-unused
UnitExists perf-cache local.
This commit is contained in:
Brues
2026-07-30 13:45:53 -05:00
parent a8b131898b
commit 305ff6c86e
+4 -6
View File
@@ -4,7 +4,6 @@ pfUI:RegisterModule("nameplates", function ()
-- Local function references for performance -- Local function references for performance
local GetTime = GetTime local GetTime = GetTime
local UnitExists = UnitExists
local UnitName = UnitName local UnitName = UnitName
local UnitClass = UnitClass local UnitClass = UnitClass
local UnitLevel = UnitLevel local UnitLevel = UnitLevel
@@ -180,7 +179,6 @@ pfUI:RegisterModule("nameplates", function ()
-- ============================================================================ -- ============================================================================
local frameState = { local frameState = {
now = 0, now = 0,
hasTarget = false,
targetGuid = nil, targetGuid = nil,
mouseoverGuid = nil, mouseoverGuid = nil,
} }
@@ -498,7 +496,7 @@ nameplates:RegisterEvent("SPELL_FAILED_OTHER")
CacheConfig() CacheConfig()
this:SetGameVariables() this:SetGameVariables()
RebuildRaidGuidCache() RebuildRaidGuidCache()
frameState.hasTarget, frameState.targetGuid = UnitExists("target"), UnitGUID("target") frameState.targetGuid = UnitGUID("target")
end end
-- Handle friendly zone nameplate disable feature -- Handle friendly zone nameplate disable feature
@@ -661,7 +659,7 @@ nameplates:RegisterEvent("SPELL_FAILED_OTHER")
end end
elseif event == "PLAYER_TARGET_CHANGED" then elseif event == "PLAYER_TARGET_CHANGED" then
frameState.hasTarget, frameState.targetGuid = UnitExists("target"), UnitGUID('target') frameState.targetGuid = UnitGUID('target')
-- Flag the target's plate for update -- Flag the target's plate for update
local plate = C_NamePlate.GetNamePlateForUnit("target") local plate = C_NamePlate.GetNamePlateForUnit("target")
if plate and plate.nameplate then if plate and plate.nameplate then
@@ -1339,7 +1337,7 @@ nameplates:RegisterEvent("SPELL_FAILED_OTHER")
-- and immediately correct on de-target (unlike istarget which updates one tick later) -- and immediately correct on de-target (unlike istarget which updates one tick later)
local targetGuid = state and state.targetGuid local targetGuid = state and state.targetGuid
local target = (targetGuid and nameplate.cachedGuid and targetGuid == nameplate.cachedGuid) or local target = (targetGuid and nameplate.cachedGuid and targetGuid == nameplate.cachedGuid) or
(state and state.hasTarget and frame:GetAlpha() >= 0.99) or nil (state and state.targetGuid and frame:GetAlpha() >= 0.99) or nil
-- Target plate castbar runs on its own dedicated frame (nameplates.castbarFrame). -- Target plate castbar runs on its own dedicated frame (nameplates.castbarFrame).
-- For non-target plates with castbar active, use castbar throttle to ensure -- For non-target plates with castbar active, use castbar throttle to ensure
-- smooth animation without overloading the central loop. -- smooth animation without overloading the central loop.
@@ -1453,7 +1451,7 @@ nameplates:RegisterEvent("SPELL_FAILED_OTHER")
-- Set non-target plate alpha -- Set non-target plate alpha
local configAlpha = cfg.notargalpha or 0.5 local configAlpha = cfg.notargalpha or 0.5
local desiredAlpha = (target or not state.hasTarget) and 1 or configAlpha local desiredAlpha = (target or not state.targetGuid) and 1 or configAlpha
if nameplate.cachedAlpha ~= desiredAlpha then if nameplate.cachedAlpha ~= desiredAlpha then
nameplate:SetAlpha(desiredAlpha) nameplate:SetAlpha(desiredAlpha)