View Single Post
03-29-09, 02:16 PM   #18
Foxlit
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 91
Originally Posted by watchout View Post
One thing to also note is: Avoid global tables at all costs. WoWs current global table is so overpopulated that you're almost always faster when you first do local x = sometableinglobal; and then do your operations on x. You're even faster if you completely skip the global table and stay within your addon's scope (have a table where everything is inside that you can access using self, or use local-to-file variables if possible).
The number of entires in the global environment has nothing to do with this. There's generally no difference in access time between "large" and "small" hash tables -- the number of buckets is simply increased when more entires are added, which is a one-time cost when the table is rehashed. The entire "overpopulated table" line of reasoning is invalid.

The performance difference you observe is caused by only looking up "sometableinglobal" once, rather than every time you access it. This applies to *all* nested tables: if you're performing a large number of operations on some sub-table, use a local reference rather than looking it up in its parent table every time.
__________________
... and you do get used to it, after a while.
  Reply With Quote