mirror of
https://github.com/brues-code/SuperCleveRoidMacros.git
synced 2026-09-16 03:38:00 +00:00
Cut per-call allocations in the event and publish paths; merge SPELL_CAST_EVENT
Chasing high memory churn (~188 kb/s with pfUI). Four allocation sources and one correctness bug found along the way. The recurring cause: in 1.12's Lua 5.0 a function declared `function(...)` builds a fresh `arg` table on every call. Three handlers were declared that way and none of them read the vararg. - Compatibility/pfUI.lua: the registered action handler. This was the dominant one. UpdateAllManagedCooldowns fans ACTIONBAR_UPDATE_COOLDOWN across every managed slot (up to 120) on each SPELL_UPDATE_COOLDOWN, so every GCD and cooldown tick allocated ~120 tables that the handler then discarded, because its whole body only ever applied to ACTIONBAR_SLOT_CHANGED. Dropped the vararg and added an early return before any work. Bongos' and UltimaMacros' handlers were already vararg-free. - Core.lua SendEventForAction: dropped the vararg (every caller passes exactly one extra value) and replaced the inline "arg" .. i concatenations -- 30 per call across three loops -- with a prebuilt name table. The eight-branch arg.n fan-out collapses to one loop. - Core.lua Frame OnEvent dispatcher: dropped the vararg. It fires for all ~48 registered events, including the UNIT_HEALTH / UNIT_AURA / UNIT_*_GUID streams. PublishDisplay now skips no-op publishes. Publishing is not free: the client repaints holders of the macro through its own notifier, which returns as ACTIONBAR_SLOT_CHANGED -> ClearAction + IndexActionSlot -> TestForActiveAction -> publish. Publishing an unchanged value therefore tore down and re-resolved slots for nothing and fed itself, since GetAction and IndexActionSlot both publish on paths that fire constantly. This was the C_Macro.SetMacroDisplay regression. Also merges the two same-named SPELL_CAST_EVENT handlers. Lua assigns in file order, so the later definition silently replaced the earlier one and its half never ran: channel-start detection, spell_tracking cleanup, and cast-sequence advancement. AdvanceSequence has only two callers and the other is inside UNIT_CASTEVENT, which is registered only under SuperWoW -- so /castsequence had no way to advance on a successful cast for Nampower-only users.
This commit is contained in:
+24
-16
@@ -429,7 +429,17 @@ function Extension.RegisterPfUIActionEventHandler()
|
||||
-- Register a handler that will be called whenever CleveRoids updates macro states
|
||||
if CleveRoids.RegisterActionEventHandler then
|
||||
Extension.DLOG("Registering pfUI action event handler")
|
||||
CleveRoids.RegisterActionEventHandler(function(slot, event, ...)
|
||||
-- Declared without `...` on purpose: in 1.12's Lua 5.0 a vararg function
|
||||
-- allocates an `arg` table on every call, and this handler never read it.
|
||||
-- That mattered because UpdateAllManagedCooldowns fans
|
||||
-- ACTIONBAR_UPDATE_COOLDOWN out across every managed slot -- up to 120 calls
|
||||
-- -- on each SPELL_UPDATE_COOLDOWN, which fires on every GCD and cooldown
|
||||
-- tick. Those calls all allocated a table and then did nothing, because the
|
||||
-- whole body only ever applied to ACTIONBAR_SLOT_CHANGED. Hence the early
|
||||
-- return before any work.
|
||||
CleveRoids.RegisterActionEventHandler(function(slot, event)
|
||||
if event ~= "ACTIONBAR_SLOT_CHANGED" then return end
|
||||
|
||||
local button = pfUI.bars and pfUI.bars.buttons and pfUI.bars.buttons[slot]
|
||||
|
||||
if Extension.Debug then
|
||||
@@ -441,23 +451,21 @@ function Extension.RegisterPfUIActionEventHandler()
|
||||
))
|
||||
end
|
||||
|
||||
-- For slot change events, do a full button update so the icon,
|
||||
-- cooldown, and tooltip refresh through CleveRoids' hooked
|
||||
-- GetActionTexture / GetActionCooldown / GameTooltip:SetAction.
|
||||
-- Full button update so the icon, cooldown and tooltip refresh.
|
||||
-- pfUI's ButtonMacroScan defers to us for managed macros (leaves
|
||||
-- spellslot nil), so its ButtonFullUpdate routes through those hooks
|
||||
-- and follows the active conditional — no manual cooldown override
|
||||
-- needed.
|
||||
if event == "ACTIONBAR_SLOT_CHANGED" then
|
||||
-- Mark the slot for update in pfUI's cache (processed next OnUpdate)
|
||||
if pfUI.bars and pfUI.bars.update then
|
||||
pfUI.bars.update[slot] = true
|
||||
end
|
||||
-- spellslot nil), so ButtonFullUpdate reads the stock action-bar
|
||||
-- functions -- which now resolve through the value we publish with
|
||||
-- C_Macro.SetMacroDisplay, rather than the Lua overrides this addon
|
||||
-- used to install.
|
||||
|
||||
-- Also directly call ButtonFullUpdate if the button exists
|
||||
if button and pfUI.bars.ButtonFullUpdate then
|
||||
pfUI.bars.ButtonFullUpdate(button)
|
||||
end
|
||||
-- Mark the slot for update in pfUI's cache (processed next OnUpdate)
|
||||
if pfUI.bars and pfUI.bars.update then
|
||||
pfUI.bars.update[slot] = true
|
||||
end
|
||||
|
||||
-- Also directly call ButtonFullUpdate if the button exists
|
||||
if button and pfUI.bars.ButtonFullUpdate then
|
||||
pfUI.bars.ButtonFullUpdate(button)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user