Hyphenation: speed up book loading by setting hyph algo earlier (#4142)

Setting the hyph algo before loading the document may save crengine
from re-doing some expensive work at render time (the hyph algo
is accounted in the nodeStyleHash, and would cause a mismatch if it is
different at render time from how it was at load time - "English US" by
default - causing a full re-init of the nodes styles.)
We will only re-set it on pre-render (only then, after loading, we
know the document language) if it's really needed: when no algo saved
in book settings, no default algo, and book has some language defined.
This commit is contained in:
poire-z
2018-08-07 18:37:52 +02:00
committed by Frans de Jonge
parent bb949afb7f
commit c1206888ab
2 changed files with 75 additions and 11 deletions

View File

@@ -163,8 +163,12 @@ end
function CreDocument:loadDocument(full_document)
if not self._loaded then
local only_metadata = full_document == false
logger.dbg("CreDocument: loading document...")
if self._document:loadDocument(self.file, only_metadata) then
self._loaded = true
logger.dbg("CreDocument: loading done.")
else
logger.dbg("CreDocument: loading failed.")
end
end
return self._loaded
@@ -178,10 +182,12 @@ function CreDocument:render()
< DCREREADER_TWO_PAGE_THRESHOLD then
self:setVisiblePageCount(1)
end
logger.dbg("CreDocument: rendering document...")
self._document:renderDocument()
if not self.info.has_pages then
self.info.doc_height = self._document:getFullHeight()
end
logger.dbg("CreDocument: rendering done.")
end
function CreDocument:close()