From 019c980eeaadb5d2dde4b6d3bcc16912decc7b4b Mon Sep 17 00:00:00 2001 From: shagu Date: Sun, 5 Aug 2018 22:00:55 +0200 Subject: [PATCH] api: reduce memory load in HookScript call --- api/api.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/api/api.lua b/api/api.lua index 8a744839..d2d91d49 100644 --- a/api/api.lua +++ b/api/api.lua @@ -310,12 +310,15 @@ function pfUI.api.hooksecurefunc(name, func, append) _G[name] = pfUI.hooks[tostring(func)]["function"] end +-- [ HookScript ] +-- Sets a function to be called automatically after the original function is called +-- 'f' [frame] the frame that should get a function hook +-- 'script' [string] the name of the function that should be hooked +-- 'func' [function] the function that should run after the original one function pfUI.api.HookScript(f, script, func) local prev = f:GetScript(script) - - f:SetScript(script, function(...) + f:SetScript(script, function() if prev then prev() end - func() end) end