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:
local t = {
["Throne of the Tides"] = {
["Order"] = "Lady Naz'jar:Commander Ulthok:Mindbender Ghur'sha:Ozumat:Trash",
["Lady Naz'jar"] = {
["Order"] = "Normal:Heroic",
["Normal"] = "55202,55198,55195,55201,55203",
["Heroic"] = "56267,56269,56268,56270,56266",
},
...
],
}
(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:
local t = {
["Throne of the Tides"] = {
[1] = {
label = "Lady Naz'jar",
data = {
[1] = {
label = "Normal",
items = "55202,55198,55195,55201,55203",
},
[2] = {
label = "Heroic",
items = "56267,56269,56268,56270,56266",
},
},
},
},
}
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.