Thread Tools Display Modes
Prev Previous Post   Next Post Next
11-30-10, 10:12 AM   #1
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
Table Structure

Hello all.

Looking for some thoughts about table structure. I'm making an AtlasLoot-type addon which obviously has tables upon tables with items.

At the moment, the structure of a module-table look like this (for example):

lua Code:
  1. local t = {
  2.     ["Throne of the Tides"] = {
  3.         ["Order"] = "Lady Naz'jar:Commander Ulthok:Mindbender Ghur'sha:Ozumat:Trash",
  4.         ["Lady Naz'jar"] = {
  5.             ["Order"] = "Normal:Heroic",
  6.             ["Normal"] = "55202,55198,55195,55201,55203",
  7.             ["Heroic"] = "56267,56269,56268,56270,56266",
  8.         },
  9.         ...
  10.     ],
  11. }

(I know it's not localized etc, but not worrying about that right now.)

I use the field Order to make sure stuff is ordered properly since you can't trust the table (when used as a dictionary) to have the same structure. I guess my question is, is this a inefficient way to do it? When retrieving the data I do for match in string.gmatch(table.Order, "[^:]+") do.

Would a structure like this be more efficient/memory-friendly?

lua Code:
  1. local t = {
  2.     ["Throne of the Tides"] = {
  3.         [1] = {
  4.             label = "Lady Naz'jar",
  5.             data = {
  6.                 [1] = {
  7.                     label = "Normal",
  8.                     items = "55202,55198,55195,55201,55203",
  9.                 },
  10.                 [2] = {
  11.                     label = "Heroic",
  12.                     items = "56267,56269,56268,56270,56266",
  13.                 },
  14.             },
  15.         },
  16.     },
  17. }

Guessing this might be less efficient perhaps, due to it containing more nested tables. I suppose I could embed the label in the item-string as well and just getting that one out when "unpacking" stuff. Something like [1] = "Normal:55202,55198,55195,55201,55203".

Or is either of these ways completely bonkers? It's hard to draw any conclusions by looking at how much memory the addon uses in total, if it's "too much" or not.

Thankful for any input.
__________________
Oh, the simulated horror!
  Reply With Quote
 

WoWInterface » Developer Discussions » General Authoring Discussion » Table Structure


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