From kde-commits Mon Jan 10 20:46:20 2011 From: =?utf-8?q?Aaron=20J=2E=20Seigo?= Date: Mon, 10 Jan 2011 20:46:20 +0000 To: kde-commits Subject: KDE/kdelibs/kdeui/icons Message-Id: <20110110204620.60233AC8B2 () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=129469242506269 SVN commit 1213567 by aseigo: an entire pixmap cache just to cache the values of the group sizes! it used to be used for many more things, which made this more sensible. not so much anymore. what this does mean is that ~37ms of CPU time (on my laptop anyways) is moved up into KIconLoader's init rather than on first icon fetch. what is saved is the time to create the icon cache itself (negligable: ~2ms on my system) and the memory overhead. this "frees" KIconLoader from KIconCache and therefore also KPixmapCache. we can now remove the class in "KDE5" as noted in the comments in the header. M +11 -29 kiconloader.cpp --- trunk/KDE/kdelibs/kdeui/icons/kiconloader.cpp #1213566:1213567 @@ -61,7 +61,6 @@ // kdeui #include "kicontheme.h" #include "kiconeffect.h" -#include "kiconcache.h" #include "k3icon_p.h" // Used to make cache keys for icons with no group. Result type is QString* @@ -74,8 +73,6 @@ // (ereslibre) #undef KDE_QT_SVG_RENDERER_FIXED -//#define NO_LAZYLOAD_ICONTHEME - /** * Checks for relative paths quickly on UNIX-alikes, slowly on everything else. */ @@ -170,7 +167,6 @@ KIconLoaderPrivate(KIconLoader *q) : q(q) , mpGroups(0) - , mIconThemeCache(0) , mIconCache(0) { } @@ -181,7 +177,6 @@ deleted when the elements of d->links are deleted */ qDeleteAll(links); delete[] mpGroups; - delete mIconThemeCache; delete mIconCache; } @@ -295,7 +290,6 @@ KStandardDirs *mpDirs; KIconEffect mpEffect; QList links; - KIconCache* mIconThemeCache; // This shares the icons across all processes KSharedDataCache* mIconCache; @@ -482,43 +476,32 @@ // smaller. mPixmapCache.setMaxCost(10 * 1024 * 1024); - // Initialize icon theme cache - mIconThemeCache = new KIconCache; - if (!mIconThemeCache->isValid()) { - initIconThemes(); - QList allThemes; - foreach (KIconThemeNode* node, links) { - allThemes.append(node->theme); - } - mIconThemeCache->setThemeInfo(allThemes); - } - // These have to match the order in kicontheme.h static const char * const groups[] = { "Desktop", "Toolbar", "MainToolbar", "Small", "Panel", "Dialog", 0L }; KSharedConfig::Ptr config = KGlobal::config(); // loading config and default sizes + initIconThemes(); + KIconTheme *defaultSizesTheme = links.empty() ? 0 : links.first()->theme; mpGroups = new KIconGroup[(int) KIconLoader::LastGroup]; - for (KIconLoader::Group i=KIconLoader::FirstGroup; i8) + if (QPixmap::defaultDepth() > 8) { mpGroups[i].alphaBlending = cg.readEntry("AlphaBlending", true); - else + } else { mpGroups[i].alphaBlending = false; - - if (!mpGroups[i].size) - mpGroups[i].size = mIconThemeCache->defaultIconSize(i); } -#ifdef NO_LAZYLOAD_ICONTHEME - initIconThemes(); -#endif + if (!mpGroups[i].size && defaultSizesTheme) { + mpGroups[i].size = defaultSizesTheme->defaultSize(i); } + } +} bool KIconLoaderPrivate::initIconThemes() { @@ -1187,7 +1170,6 @@ QString *path_store, bool canReturnNull) const { QString name = _name; - bool unknownIcon = false; bool favIconOverlay = false; if (size < 0 || _name.isEmpty())