Patch: using KSharedConfig in KIconTheme

David Faure faure at kde.org
Tue Mar 9 17:40:18 CET 2004


From looking at which config files we ask KConfig to parse, I noticed that
we parse crystalsvg/index.theme many times during application startup.

E.g. in kword there are two KInstances (the shell and the part) (apps with plugins
get many more), each KInstance has an iconloader, and each iconloader has
four KIconThemes (crystalsvg kword, hicolor kword, crystalsvg koffice, hicolor koffice),
due to theme inheritance and to the addAppDirs("koffice") call.
So that's 4 instances of KIconTheme parsing crystalsvg/index.theme,
and 4 instances parsing hicolor/index.theme.

What about using KSharedConfig there to parse those files only once?
See attached patch.

The drawback is that we keep the kconfig object in memory instead of discarding
it at the end of the KIconTheme constructor each time.... so this is a usual cpu 
vs memory tradeoff, which makes me a bit unsure whether this is wanted.

Somehow we'd need to keep the ksharedconfigs around during the whole
startup phase, but discard them for the rest of the app's lifetime.
Maybe this could be done using a QTimer? e.g. singleShot timer from
KIconTheme that would reset d->sharedConfig to 0. But that's 8 timers
(in kword's case) firing the first time we get to the event loop, is that a problem?

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kicontheme.cpp.diff
Type: text/x-diff
Size: 995 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-optimize/attachments/20040309/94108905/kicontheme.cpp.bin


More information about the Kde-optimize mailing list