optimization

This commit is contained in:
Manuel Simon Hirsig
2018-02-17 13:15:57 +01:00
parent bf0b70e33f
commit 60fdb00a6b
+6 -3
View File
@@ -294,10 +294,10 @@ function M.tooltip(setter, arg1, arg2)
return tooltip, AuxTooltip.money return tooltip, AuxTooltip.money
end end
do
local pattern = '^' .. gsub(gsub(ITEM_SPELL_CHARGES_P1, '%%d', '(%%d+)'), '%%%d+%$d', '(%%d+)') .. '$'
function item_charges(tooltip) function item_charges(tooltip)
for _, line in tooltip do for _, line in tooltip do
local pattern = '^' .. gsub(gsub(ITEM_SPELL_CHARGES_P1, '%%d', '(%%d+)'), '%%%d+%$d', '(%%d+)') .. '$'
local _, _, left_charges_string = strfind(line.left_text or '', pattern) local _, _, left_charges_string = strfind(line.left_text or '', pattern)
local _, _, right_charges_string = strfind(line.right_text or '', pattern) local _, _, right_charges_string = strfind(line.right_text or '', pattern)
@@ -308,6 +308,7 @@ function item_charges(tooltip)
end end
return 1 return 1
end end
end
do do
local data = { local data = {
@@ -340,9 +341,10 @@ do
end end
end end
do
local pattern = '^' .. gsub(gsub(DURABILITY_TEMPLATE, '%%d', '(%%d+)'), '%%%d+%$d', '(%%d+)') .. '$'
function M.durability(tooltip) function M.durability(tooltip)
for _, line in tooltip do for _, line in tooltip do
local pattern = '^' .. gsub(gsub(DURABILITY_TEMPLATE, '%%d', '(%%d+)'), '%%%d+%$d', '(%%d+)') .. '$'
local _, _, left_durability_string, left_max_durability_string = strfind(line.left_text or '', pattern) local _, _, left_durability_string, left_max_durability_string = strfind(line.left_text or '', pattern)
local _, _, right_durability_string, right_max_durability_string = strfind(line.right_text or '', pattern) local _, _, right_durability_string, right_max_durability_string = strfind(line.right_text or '', pattern)
local durability = tonumber(left_durability_string) or tonumber(right_durability_string) local durability = tonumber(left_durability_string) or tonumber(right_durability_string)
@@ -352,6 +354,7 @@ function M.durability(tooltip)
end end
end end
end end
end
function M.item_key(link) function M.item_key(link)
local item_id, suffix_id = parse_link(link) local item_id, suffix_id = parse_link(link)