mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user