View Single Post
03-23-13, 01:32 AM   #10
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
In this post, I'll be referring to the actual code in use as linked.

Since the table tracks is registered as an upvalue already, I'll address a solution to assigning a series of values to it in the function. The way it is set up now, it's going to create a new table every time the function runs. The brackets used to define the table are actually called the Table Constructor and their entire purpose is to build a new table with the values given inserted initially.

What I suggest is to replace line 380 with the following:
Lua Code:
  1. table.wipe(tracks);
  2. for i in string.gmatch(db.profile["Bars"][x][y].track,"[^#]+") do tinsert(tracks,i); end

What this does is runs a pattern-matching iterator to reconstruct the table in the same manner strsplit() would, reusing the old table instead of creating a new one each time. The pattern string I provided tells it to return chunks of the string that doesn't include the hash (#) symbol.

For more information (official Lua documentation):
String Functions - http://www.lua.org/manual/5.1/manual.html#5.4
Patterns - http://www.lua.org/manual/5.1/manual.html#5.4.1
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote