Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Hyphenation: speed up book loading by setting hyph algo earlier #4142
The hyphenation algo setup was the only one using onPreRenderDocument, because it needed access to the document language to set accordingly the hyphenation algorithm.
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.)
Before, the hyphenation settings were only and always applied after loading. It was working similar to this (with the logs this PR adds):
Now, we can get this:
and only when necessary this full re-rendering:
On my big sample book (which gets another
Aug 7, 2018
1 check passed
Well, this speedup is noticable mostly on the first opening of big books. On next openings, if a cache is re-used, this late hyphenation wouldn't cause any problem, and the already fast loading won't get any faster.