View Single Post
07/03/14, 03:19 AM   #3
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
As Sasky said, perfromce is indeed a secondary concern.
There is one reason a thousand times more important to prefer local variables:
Global in Lua is more global then any other language. The global namespaces is shared between your addons filles, all other addons and even Zenimax own code.

For example I am able to override GetDisplayName() (because it is global) and Zenimax own SavedVar code will use my overridden version. Don't use global unless you are really, REALLY certain what you are doing.

For tables keep in mind that you are copying only the reference. So both variables will still point to the same table (call by reference).
Note that there is a build in function for cloning tables:
ZO_DeepTableCopy(source, dest)

Last edited by zgrssd : 07/03/14 at 03:28 AM.
  Reply With Quote