View Single Post
05-15-13, 07:32 AM   #6
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
In the initial example, since the function is called over and over many times, I would think
Lua Code:
  1. local newVar = UPVALUE_VAR
  2. local function MyFunction()
  3.     -- do something with newVar
  4. end
Would be much better than
Lua Code:
  1. local function MyFunction()
  2.     local newVar = UPVALUE_VAR
  3.     -- do something with newVar
  4. end
Simply because you are assigning newVar once rather than repeatedly, especially since its value never changes. That said, is assigning upvalues a performance gain? That's a different story.
  Reply With Quote