So… firing up perf record and hotspot, with OpenDocument spec 1.2 (that's what I found in my homedir)…
It takes about 21s to load, of which 34% is spent parsing the document (7s, still too much, but let's accept it so far) and 59% of the time is spent layouting. 14% of time is spent in KoTextRange::document() from KoTextRangeManager::textRangesChangingWithin. I've optimized this to remove this call to document, but I gained only 1s. I've done another minor optimization and found on my way that having private classes embedded in std::unique_ptr kills performance, but this will deserve a message on its own. Since the fastest code is the one we don't call, I've written a completely different way that doesn't call textRangesChangingWithin anymore. Much faster since I'm now down to 15s. All this is in my work/ducroquet/perfs-words branch. Feel free to have a look, I'll keep digging into this in the afternoon and the next days.
signature.asc
Description: This is a digitally signed message part.