View Single Post
04/17/14, 04:02 PM   #13
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
  1. Always use events instead of an OnUpdate script if events are available.

  2. If you must use an OnUpdate script, then buffer that OnUpdate script so that it's not called on each and every frame draw (if you have 50fps, that's 50 times per second your function is trying to run).

  3. Always make your variables/functions/etc. local unless you must have them in the global scope. If they have to be global, then give them unique names. AutoHide, menu1, etc. are not unique. If another developer slips and leaks a variable named menu1 into the global scope, the two variables will overwrite one another. Keeping them local avoids this problem, and is better for performance.

  4. Don't use string.format if you're not actually doing any formatting. Just use :SetText("text"). It'll save you a function call.

  5. The backdrop and label are children of your myAddonUI control. As I explained earlier in this thread, they will inherit visibility from their parent. Don't call :SetHidden() for these. Just call :SetHidden() on the parent frame. And then you can leave the :SetMouseEnabled() call out of it. Because it'll be hidden. This will save you two function calls here.
  Reply With Quote