View Single Post
12-31-13, 08:43 PM   #27
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Xrystal, the main problem with your implmentation (aside from questionable coding practices) is that you're spending CPU and memory re-coloring the same name with the same color every time you get a message. It's more efficient to just update a static list whenever a friend's status changes, so you can just do a simple table lookup for each message, instead of needing to call functions and format strings.

Originally Posted by Wimpface View Post
Is line 80 supposed to read like that? Won't this throw an error?
Yes, and your correction is correct.

Originally Posted by Xrystal View Post
Thanks for the input Phanx. Did a bit of research on the difference between table based variables and standalone variables and there is a slight improvement on performance and of course readability. I am guessing that is why you are saying not to use them, you weren't clear there. I will of course take it under advisement when finalising the addon beyond this testing phase.
Creating a variable is basically free, as the value already exists in memory, and you're just pointing to it. Creating a table is not free, as the object does not already exist, and creating it takes up space in memory. Discarding a table is also more expensive than discarding a variable, since in addition to the values, the garbage collector must also collect the table object containing them. Finally, looking up a value in a table is more expensive that simply reading a variable. Between all this, and the fact that there's absolutely no upside to using a table like this, and the fact that you have to remember what each value in the argument list was instead of being able to give them descriptive names, there's just no reason to ever use a table this way. I cringe just imagining whatever nightmarish cesspool of terrible example code you got that idea from in the first place.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote