Originally Posted by Recompense
A naive performance issue question - what's the drag on speed if you're saving the variable every single time the box has a text edit? I know that it's tiny, but I'm trying to learn more about which methods of saving / accessing data are the fastest for best practices.
|
When considering performance, I divide it into two mind sets.
1) Addon Configuration - Don't worry too much about CPU usage, just don't make excessive garbage.
2) Addon Normal Usage - code for best possible performance.
But, yeah, setting the var with the script handler is not really going to affect anything. Now, if you were doing some very complex script calls (lots of table creation, sorting, what have you, then yeah, using OnTextChanged would not be ideal.
Bascially, you don't want to code yourself out of an easy solution just because you get OCD on CPU usuage. You have to keep in mind what the user is doing at the time the frame is being used or the function is being called. If it is used in a limited scope, then use the easy solution, which to me, is the snippet I posted above
If the editbox was being used in combat, then I might opt for the <OnEnteredPressed> script handler. I like <OnTextChanged> just because it will grab the entered data no matter how the user leaves the edit box (enter, escape, tab, alt-f4, whatever)
But for the OP's purposes, performance should not be an issue using that script handler.