In the initial example, since the function is called over and over many times, I would think
Lua Code:
local newVar = UPVALUE_VAR
local function MyFunction()
-- do something with newVar
end
Would be much better than
Lua Code:
local function MyFunction()
local newVar = UPVALUE_VAR
-- do something with newVar
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.