credocument reader optimisation (avoid multiple TOC builds) (#3292)

Avoid unnecessary work in ReaderView:onSetViewMode() and
ReaderRolling:updatePos() that would result in TOC being reset
and rebuilt (which can take time on books with huge TOC) during
reader setup.
This commit is contained in:
poire-z
2017-10-03 00:31:14 +02:00
committed by GitHub
parent e5675af467
commit 26def92983
3 changed files with 10 additions and 6 deletions

View File

@@ -96,9 +96,9 @@ function CreDocument:init()
-- @TODO check the default view_mode to a global user configurable
-- variable 22.12 2012 (houqp)
local ok
ok, self._document = pcall(cre.newDocView,
Screen:getWidth(), Screen:getHeight(), self.PAGE_VIEW_MODE
)
ok, self._document = pcall(cre.newDocView, Screen:getWidth(), Screen:getHeight(),
DCREREADER_VIEW_MODE == "scroll" and self.SCROLL_VIEW_MODE or self.PAGE_VIEW_MODE
) -- this mode must be the same as the default one set as ReaderView.view_mode
if not ok then
error(self._document) -- will contain error message
end