Sluimerstand / ProfessionShoppingList

Track recipes, reagents, cooldowns, and more!
5 stars 3 forks source link

Suggestion for usage of `UNIT_SPELLCAST_SUCCEEDED` #75

Closed tflo closed 1 year ago

tflo commented 1 year ago

I've seen the addon is watching the UNIT_SPELLCAST_SUCCEEDED event and then checks the recipes that are being tracked.

This can be a very frequent event (especially in a crowded area), but the good thing is that it always comes with an argument that tells you who the caster is.

So, in the event conditional, the first thing I would do is check if arg1 is 'player'. (Assuming the addon is not interested in other people's spell casts). If it is not 'player', then just do nothing.

I'm not saying that your code is causing noticeable lag or anything, but if you have 100 addons loaded and 50 of them are running unnecessary routines on very frequently firing events, then it will add up 😉


Disclaimer: I've only had a quick look at the code, so it's possible I'm missing something. If the addon really needs to do something about other players' casting events, then just ignore this post.

tflo commented 1 year ago

Closing this as I am no longer using the addon.

Sluimerstand commented 1 year ago

I've implemented this one anyway, thank you for the advice. :)

tflo commented 1 year ago

Actually, my proposal was not quite accurate. You don't even have to check the argument of the event, you can already filter it when registering:

RegisterUnitEvent("UNIT_SPELLCAST_SUCCEEDED", "player")
tflo commented 1 year ago

Sorry for the late correction.