Skip to content

Commit

Permalink
fux a small mem leak as user edits custom code
Browse files Browse the repository at this point in the history
  • Loading branch information
emptyrivers authored and InfusOnWoW committed Sep 1, 2024
1 parent 50e37ae commit 353cb53
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions WeakAuras/AuraEnvironment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -642,10 +642,12 @@ local function firstLine(string)
end

local function CreateFunctionCache(exec_env)
local cache = {}
local cache = {
funcs = setmetatable({}, {__mode = "v"})
}
cache.Load = function(self, string, silent)
if self[string] then
return self[string]
if self.funcs[string] then
return self.funcs[string]
else
local loadedFunction, errorString = loadstring(string, firstLine(string))
if errorString and not silent then
Expand All @@ -655,7 +657,7 @@ local function CreateFunctionCache(exec_env)
setfenv(loadedFunction, exec_env)
local success, func = pcall(assert(loadedFunction))
if success then
self[string] = func
self.funcs[string] = func
return func
end
end
Expand Down

0 comments on commit 353cb53

Please sign in to comment.