Thread Tools Display Modes
Prev Previous Post   Next Post Next
01-16-15, 05:35 PM   #1
Sweetsour
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Dec 2014
Posts: 136
Is there a better way?

I have a curiosty I wanted to shed light on. I was curious if there's any point, or if it's worth it, to setup variables like so:

"Normal" method
Lua Code:
  1. addon.MainFrame = CreateFrame("Frame","MainFrame",UIParent);
  2.  
  3. -- Like This
  4. addon.MainFrame.MyLabel = CreateFrame("Frame",nil,addon.MainFrame);
  5. addon.MainFrame.MyLabel.Text = addon.MainFrame.MyLabel:CreateFontString(nil,"BACKGROUND","GameFontNormal");
  6. -- Or Like This
  7. addon.MyLabel = CreateFrame("Frame",nil,addon.MainFrame);
  8. addon.MyLabel.Text = addon.MyLabel:CreateFontString(nil,"BACKGROUND","GameFontNormal");

What about making a new [local] table to house frame elements?
Lua Code:
  1. local main = {};
  2. main = addon.MainFrame;
  3.  
  4. main.MyLbl = CreateFrame("Frame",nil,main,"InputBoxTemplate");
  5. main.MyLblText = main.MyLbl:CreateFontString(nil,"BACKGROUND","GameFontNormal");
  6. -- ... etc

I guess what I'm really asking is; is there extra ways to optmize variables? Also, does the length of variable names (ie. "addon.MainFrame.MyLabel.Text" vs "main.MyLblText") affect overall addon performance?
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Is there a better way?


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