Skip to content

Commit

Permalink
Improve performance of Lazy vars (FAForever#3767)
Browse files Browse the repository at this point in the history
  • Loading branch information
4z0t authored Apr 6, 2022
1 parent 8b40229 commit b2225e0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lua/lazyvar.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
--
-- LazyVar module
--

local pcall = pcall
local TableInsert = table.insert
local iscallable = iscallable
local ipairs = ipairs
local setmetatable = setmetatable

local EvalContext = nil

Expand Down Expand Up @@ -47,7 +51,7 @@ end
function LazyVarMetaTable:SetDirty(onDirtyList)
if self[1]~=nil then
if self.OnDirty then
table.insert(onDirtyList, self)
TableInsert(onDirtyList, self)
end
self[1] = nil
local u for u in self.used_by do
Expand Down Expand Up @@ -105,7 +109,7 @@ function LazyVarMetaTable:Destroy()
end

function Create(initial)
result = {&1&4}
local result = {&1&4}
setmetatable(result, LazyVarMetaTable)
if initial == nil then
result[1] = 0
Expand Down

0 comments on commit b2225e0

Please sign in to comment.