QuestieNameplate.lua wastes CPU even when nameplates are disabled.
Arcitec opened this issue ยท 2 comments
QuestieEventHandler.lua:
_EventHandler:QuestLogUpdate()
always callsQuestieNameplate:UpdateNameplate()
whenever the quest status updates. This is fine.- It also installs the following event hooks that always run. This is fine too, as long as the functions they call don't do a bunch of needless work. Unfortunately, they do that.
Questie:RegisterEvent("NAME_PLATE_UNIT_ADDED", QuestieNameplate.NameplateCreated)
Questie:RegisterEvent("NAME_PLATE_UNIT_REMOVED", QuestieNameplate.NameplateDestroyed)
Questie:RegisterEvent("PLAYER_TARGET_CHANGED", QuestieNameplate.DrawTargetFrame)
QuestieNameplate.lua:
QuestieNameplate:UpdateNameplate()
always does processing even when Questie nameplate icons are disabled.- The same is true of
QuestieNameplate:NameplateDestroyed()
which fires every time a nameplate is removed, and does work even if nameplate icons are disabled. - The only function that preserves CPU by checking "are questie nameplate icons enabled?" before it does work, is
QuestieNameplate:NameplateCreated()
, which aborts if nameplates are disabled.
Proposed Change:
- Look at
QuestieNameplate:NameplateCreated()
and add the same kind of defensive code to all the other functions (UpdateNameplate
andNameplateDestroyed
). This is the code it uses, to avoid wasting energy doing work when it's not necessary:
if (not Questie.db.global.nameplateEnabled) then
return
end
Seems ok propose as Questie's nameplate frames are removed/destroyed with QuestieNameplate:HideCurrentFrames()
when an user disables Questie's setting for nameplates. So proposed skipping "NAME_PLATE_UNIT_REMOVED" / NameplateDestroy() events won't leave ghost frames.
Even more efficient would be to have nameplate events registered only while the setting is active.
Hey @Bananaman
it looks like you know much about Lua and also took your time to dig into the Questie code. Thanks already for this and bringing this issue along with the others to the light.
Since the team is pretty understaffed, especially for all the possible improvements and feature request, we really appreciate any help we can get.
Do you think you could tackle something and submit a PR for the improvements you suggested? ๐