Skip to content

Commit f2fc35e

Browse files
committed
Cache TSM frame to avoid CPU issue by repeatedly scanning for it.
1 parent 4e8d547 commit f2fc35e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

LibMagicUtil-1.0/LibMagicUtil-1.0.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,15 @@ end
266266
-- Finds TSM's mail window by looking for the MailsScrollTable element
267267
-- (unique to TSM's mail UI) and walking up to the top-level parent.
268268
local cachedTSMMailFrame
269+
local tsmScanComplete = false
269270
local function FindTSMMailFrame()
270271
if cachedTSMMailFrame then
271272
return cachedTSMMailFrame
272273
end
274+
-- Only scan once; if TSM frame wasn't found, it won't appear mid-session
275+
if tsmScanComplete then
276+
return nil
277+
end
273278
-- Find MailsScrollTable, then walk up to the LargeApplicationFrame
274279
local frame = EnumerateFrames()
275280
while frame do
@@ -281,13 +286,15 @@ local function FindTSMMailFrame()
281286
local parentName = parent:GetName()
282287
if parentName and type(parentName) == "string" and parentName:match("^TSM_FRAME:LargeApplicationFrame:") then
283288
cachedTSMMailFrame = parent
289+
tsmScanComplete = true
284290
return parent
285291
end
286292
parent = parent:GetParent()
287293
end
288294
end
289295
frame = EnumerateFrames(frame)
290296
end
297+
tsmScanComplete = true
291298
return nil
292299
end
293300

0 commit comments

Comments
 (0)