Content deleted Content added
cache all of the things that used to be called with maybeCallFunc |
undo memoization changes in the Row object, and instead memoize errors in CollapsibleNotice:exportHtml, which is what was actually getting called more than once |
||
Line 35:
local function makeUrlLink(url, display)
return string.format('[%s %s]', url, display)
end▼
local function maybeCallFunc(val, ...)
-- Checks whether val is a function, and if so calls it with the specified▼
if type(val) == 'function' then▼
else▼
end▼
end
Line 120 ⟶ 130:
obj.makeData = data.makeData -- used by Row:getData
return obj
▲end
▲ -- Checks whether val is a function, and if so calls it with the specified
▲ -- arguments. Otherwise val is returned as-is. The result is cached with
if self[cacheKey] ~= nil then▼
▲ end
▲ if type(val) == 'function' then
▲ ret = val(...)
▲ else
end▼
▲ return ret
end
Line 162 ⟶ 155:
function Row:getIcon(articleHistoryObj)
return
end
function Row:getIconCaption(articleHistoryObj)
return maybeCallFunc(self.iconCaption, articleHistoryObj, self)
)▼
end
Line 201 ⟶ 189:
function Row:getNoticeBarIcon(articleHistoryObj)
local icon = maybeCallFunc(self.noticeBarIcon, articleHistoryObj, self)
if icon == true then
icon = self:getIcon(articleHistoryObj)
Line 220 ⟶ 203:
function Row:getNoticeBarIconCaption(articleHistoryObj)
local caption =
self.noticeBarIconCaption,
articleHistoryObj,
Line 253 ⟶ 235:
function Row:getText(articleHistoryObj)
return
end
Line 609 ⟶ 591:
function Action:getName(articleHistoryObj)
return maybeCallFunc(self.actionCfg.name, articleHistoryObj, self)
end
function Action:getResult(articleHistoryObj)
return
self.actionCfg.results[self.resultId].text,
articleHistoryObj,
Line 704 ⟶ 680:
function CollapsibleNotice:getCollapsibleText(articleHistoryObj)
return maybeCallFunc(self.collapsibleText, articleHistoryObj, self)
end
Line 725 ⟶ 696:
function CollapsibleNotice:exportHtml(articleHistoryObj, isInCollapsibleTable)
return nil
▲ end
local cacheKey = isInCollapsibleTable and 'collapsible' or 'default'
if html then
▲ return self._htmlCache[cacheKey]
return html
elseif html == false then
return nil
end
local
local success, val = pcall(func, ...)
if success then
else
self._htmlCache.isError = true
self:raiseError(val)
end
end
local text = cachedTry(self.getText, self, articleHistoryObj)
if not text then
return nil
end
Line 767 ⟶ 755:
end
local icon = cachedTry(self
local collapsibleText = cachedTry(
self self, articleHistoryObj ▲ )
if isInCollapsibleTable then
local textCell = html:tag('td')
|