View Single Post
08-16-05, 08:20 AM   #5
Garoun
A Fallenroot Satyr
 
Garoun's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2005
Posts: 25
That's exactly what I was wondering wasn't sure of the proper name for those tables since I'm so use to arrays for storing multiple vaules. Maybe you know the answer to these questions about optimization.

1) Is the entire lua code loaded into memory for execution at load or is it read a line at a time. My assumption is the entire code is loaded into memory at start.

2) Which (if any) would be more 'resource' friendly and optimal in WoWAPI lua: (not written in 'true' code form)
Code:
Option 1:
Global_options = {'a','b','c'};
Warrior_options = {'d','e','f'};
Rogue_options = {'g','h','i'};

if (class==Warrior) then append Warrior_options to Global_options
else if (class==Rogue) then append Rogue_options to Global_options
Code:
Option 2:
Global_options = {'a','b','c'};

if (class==Warrior) then {
Warrior_options = {'d','e','f'};
append Warrior_options to Global_options
}
else if (class==Rogue) then {
Rogue_options = {'g','h','i'};
append Rogue_options to Global_options
}
I ask because I'm not completely sure how Lua loads it's code. The second would seem more efficient to me since it would then only have to fill the Global table and the Class table it needs to use for that run. The first option would be easier for maintenance and fast updating of new options.

A 3rd option if possible would be to create all needed tables at the beginning and then do something like, not sure if you can concat variables/strings like an Eval() in js that then act as another variable:

Code:
class = <playerclass>

Global_options = {'a','b','c'};
Warrior_options = {'d','e','f'};
Rogue_options = {'g','h','i'};

append class .. '_options' to Global_options;
The third version seems to cut down on overall code but has the issue of still defining all those tables in memory to begin but removes all the redundant logic for a per class basis.

Appologize for all the questions but thank you for the answers you've both given me so far. It's helped a lot for understanding how the language treats this kind of data; however basic it may be.
  Reply With Quote