Thread Tools Display Modes
12-28-14, 04:48 PM   #1
sirann
A Flamescale Wyrmkin
Join Date: Mar 2007
Posts: 142
Originally Posted by cokedrivers View Post
if event == "ADDON_LOADED" and arg1 == "cBuffs" then
you only have the frame registered to addon_loaded so the only event that can cause the script to fire is addon_loaded, thus making the initial part of this two part if check, redundant and unncessary.
  Reply With Quote
12-28-14, 04:50 PM   #2
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Originally Posted by sirann View Post
you only have the frame registered to addon_loaded so the only event that can cause the script to fire is addon_loaded, thus making the initial part of this two part if check, redundant and unncessary.
If I remember correctly the event fires for every addon that is loaded. I thought that's why arg1 provides the addon name.
  Reply With Quote
12-28-14, 05:23 PM   #3
sirann
A Flamescale Wyrmkin
Join Date: Mar 2007
Posts: 142
correct, all he needs is the arg1 == check, not the event check.

if arg1 == "cBuffs" then

instead of

if event == "ADDON_LOADED" and arg1 == "cBuffs" then
  Reply With Quote
12-28-14, 06:18 PM   #4
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Originally Posted by sirann View Post
correct, all he needs is the arg1 == check, not the event check.

if arg1 == "cBuffs" then

instead of

if event == "ADDON_LOADED" and arg1 == "cBuffs" then
But, but ... he is unregistering the event outside of the if statement. Or not??
  Reply With Quote
12-28-14, 06:56 PM   #5
sirann
A Flamescale Wyrmkin
Join Date: Mar 2007
Posts: 142
I'm starting to think we are speaking about two different things. I was merely adding (regardless of the code below it) that there is no need for the event check, there's only one registered, it can only fire for addon_loaded.

I believe what you are getting at, is the fact that, as currently written, this script would fire as soon as the first addon is loaded, which I'm confident is not cbuffs. Since the initial if check requirements would not be met, the script would skip to the slashcommand creation, and would then unregister the only event it's listening for. This would essentially ensure the script never fires when he wants it to.

If that's what you're saying, I agree, and in no way intended to imply or convey otherwise. I just noticed a relatively common, and small, unoptimization.

If that's not what you're saying, please expand, because I don't see where I am incorrect in my suggestion.
  Reply With Quote
12-28-14, 07:26 PM   #6
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Originally Posted by sirann View Post
If that's what you're saying, I agree, and in no way intended to imply or convey otherwise. I just noticed a relatively common, and small, unoptimization.
Thats it.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Which is Better?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off