Quantcast WoWInterface - View Single Post - Tables - count items in them
View Single Post
08-02-16, 02:29 AM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by myrroddin View Post
You should also define the table t outside the function. Right now you are (re)creating the table every time the function runs, which is terribad.
For a testing/debugging function, there's nothing wrong with recreating the table every time the function runs.

For production functions, it depends on the purpose of the table, and the frequency with which the function will be run. If it's an OnUpdate script, or running in response to UNIT_AURA events, yes, creating a new table on each run is a big no-no. If it's running in response to a user entering a slash command, or an infrequent event like PLAYER_ENTERING_WORLD, it's not really a big deal, and you should do whatever makes more sense scope-wise for the content/purpose of the table.
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote