KFilterDev changes from KDE3

David Faure faure at kde.org
Tue Mar 17 11:36:01 GMT 2009

On Tuesday 17 March 2009, Martin Koller wrote:
> Hi David,
> On Monday 16 March 2009, David Faure wrote:
> > > The only way coming close to what I need is the method,
> > > but this needs the mimetype again.
> > > static QIODevice *   device (QIODevice *inDevice, const QString &mimetype, bool autoDeleteInDevice=true)
> > 
> > Yes, this is the one you want.
> > Why is it a problem that it "needs the mimetype"? You said the kde3 code uses
> > KFilterBase::findFilterByMimeType() so surely it knows the mimetype.
> Well, I know the mimetype, but as I do a backup of a _lot_ of files,
> isn't the overhead too high to again and again calling findFilterByMimeType() 
> (as the mimetype will never change during the complete backup) ?

KFilterBase::findFilterByMimeType only loads a mimetype from ksycoca
(that's supposed to be really fast, just a dict lookup and a bit of deserialization)
and compares strings. If it really turns out to be a bottleneck, we could add
a cache in KFilterDev so that it remembers the last requested mimetype
and the KFilterBase that was created for it (with care not to leak or double-delete
kfilterbases...). In any case this can and should be handled internally in KFilterDev.

David Faure, faure at kde.org, sponsored by Qt Software @ Nokia to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).

More information about the kde-core-devel mailing list