[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: design discussion: caching QTextFormat for faster text loading
From:       zander () kde ! org
Date:       2010-08-13 11:30:53
Message-ID: 201008131330.53869.zander () kde ! org
[Download RAW message or body]

On Friday 13. August 2010 11.59.10 Jos van den Oever wrote:
> As you may have noticed, I'm working on speeding up KOffice at the moment.
> The  biggest bottleneck for the loading of documents at the moment is our
> styling system. In this mail, I want to explain why this is the case and
> give a suggestion for improving the situation.

The idea sounds intriguing :)  I like it.

There is something extra that you might be very happy to learn as this will 
make things a lot easier for you.

In QTextDocument each unique QTextFormat gets put in a list and gets an index 
that will never change over the lifetime of the QTextDocument.
See QTextDocument::allFormats().

This would mean that KoParagraphStyle::applyStyle and 
KoCharacterStyle::applyStyle could get some extra code to detect the ideal 
case; which is almost always hit in an empty document. The ideal case is when 
we apply the style on a block without style.

So a block has a format set to index (QTextBlock::blockFormatIndex) that is 
known to be 'empty' and we turn it into a know other format. The tricky part 
is that this is per QTextDocument instance.
But I bet its easy to store a little structure inside the style keeping a 
QTextDocument pointer, an int of the 'before' format Id and the new format. 
Which you just apply.

That would be fast as all you need to do for knowing you can apply the format 
is to do one integer comparison.

Hope this helps you a bit :)
-- 
Thomas Zander
_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic