Optimize tooltip hot paths
This commit is contained in:
+26
-12
@@ -210,11 +210,16 @@ function M.set_shopping_tooltip(slot)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.tooltip_match(entry, tooltip)
|
function M.tooltip_match(entry, tooltip)
|
||||||
return aux.any(tooltip, function(line)
|
local upper_entry = strupper(entry)
|
||||||
local left_match = line.left_text and strupper(line.left_text) == strupper(entry)
|
for _, line in tooltip do
|
||||||
local right_match = line.right_text and strupper(line.right_text) == strupper(entry)
|
if line.left_text and strupper(line.left_text) == upper_entry then
|
||||||
return left_match or right_match
|
return true
|
||||||
end)
|
end
|
||||||
|
if line.right_text and strupper(line.right_text) == upper_entry then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.tooltip_find(pattern, tooltip)
|
function M.tooltip_find(pattern, tooltip)
|
||||||
@@ -264,7 +269,10 @@ end
|
|||||||
|
|
||||||
function M.auctionable(tooltip, quality, strict)
|
function M.auctionable(tooltip, quality, strict)
|
||||||
local status = tooltip[2] and tooltip[2].left_text
|
local status = tooltip[2] and tooltip[2].left_text
|
||||||
local durability, max_durability = durability(tooltip)
|
local durability, max_durability
|
||||||
|
if strict then
|
||||||
|
durability, max_durability = durability(tooltip)
|
||||||
|
end
|
||||||
return (not quality or quality < 6)
|
return (not quality or quality < 6)
|
||||||
and status ~= ITEM_BIND_ON_PICKUP
|
and status ~= ITEM_BIND_ON_PICKUP
|
||||||
and status ~= ITEM_BIND_QUEST
|
and status ~= ITEM_BIND_QUEST
|
||||||
@@ -287,12 +295,18 @@ function M.tooltip(setter, arg1, arg2)
|
|||||||
end
|
end
|
||||||
local tooltip = T.acquire()
|
local tooltip = T.acquire()
|
||||||
for i = 1, AuxTooltip:NumLines() do
|
for i = 1, AuxTooltip:NumLines() do
|
||||||
tinsert(tooltip, T.map(
|
local left_line = _G['AuxTooltipTextLeft' .. i]
|
||||||
'left_text', _G['AuxTooltipTextLeft' .. i]:GetText(),
|
local right_line = _G['AuxTooltipTextRight' .. i]
|
||||||
'left_color', T.list(_G['AuxTooltipTextLeft' .. i]:GetTextColor()),
|
local right_text = right_line:IsVisible() and right_line:GetText()
|
||||||
'right_text', _G['AuxTooltipTextRight' .. i]:IsVisible() and _G['AuxTooltipTextRight' .. i]:GetText(),
|
local line = T.map(
|
||||||
'right_color', T.list(_G['AuxTooltipTextRight' .. i]:GetTextColor())
|
'left_text', left_line:GetText(),
|
||||||
))
|
'left_color', T.list(left_line:GetTextColor()),
|
||||||
|
'right_text', right_text
|
||||||
|
)
|
||||||
|
if right_text then
|
||||||
|
line.right_color = T.list(right_line:GetTextColor())
|
||||||
|
end
|
||||||
|
tinsert(tooltip, line)
|
||||||
end
|
end
|
||||||
return tooltip, AuxTooltip.money
|
return tooltip, AuxTooltip.money
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user