[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdeui/icons
From: Michael Pyne <mpyne () kde ! org>
Date: 2010-09-14 2:49:41
Message-ID: 20100914024941.DD66BAC888 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1175071 by mpyne:
Apply a patch to speedup stringifying the cache keys used in KIconLoader.
Patch was developed by Matthias Fuchs and improved on by Ingo Klöcker. This will
be in KDE Platform 4.6.
On a simple warm-cache benchmark, the makeCacheKey method being improved went from
34% of loadIcon's execution time to 13%, for an overall 8% speed improvement in icon
loading. The results become less impressive on a cold cache, but such is to be
expected.
M +13 -19 kiconloader.cpp
--- trunk/KDE/kdelibs/kdeui/icons/kiconloader.cpp #1175070:1175071
@@ -37,6 +37,7 @@
#include <QtCore/QBuffer>
#include <QtCore/QDataStream>
#include <QtCore/QByteArray>
+#include <QtCore/QStringBuilder> // % operator for QString
#include <QtGui/QIcon>
#include <QtGui/QPainter>
#include <QMovie>
@@ -758,28 +759,21 @@
QString KIconLoaderPrivate::makeCacheKey(const QString &name, KIconLoader::Group group,
const QStringList &overlays, int size, int state) const
{
- // The KSharedDataCache is shared so add some namespacing.
- QString key;
+ // The KSharedDataCache is shared so add some namespacing. The following code
+ // uses QStringBuilder (new in Qt 4.6)
- if (group == KIconLoader::User) {
- key = QLatin1String("$kicou_");
+ return (group == KIconLoader::User
+ ? QLatin1Literal("$kicou_")
+ : QLatin1Literal("$kico_"))
+ % name
+ % QLatin1Char('_')
+ % QString::number(size)
+ % QLatin1Char('_')
+ % overlays.join("_")
+ % ( group >= 0 ? mpEffect.fingerprint(group, state)
+ : QString::fromAscii("noeffect"));
}
- else {
- key = QLatin1String("$kico_");
- }
- key.append(QString("%1_%2_%3").arg(name).arg(size).arg(overlays.join("_")));
-
- if (group >= 0) {
- key.append(mpEffect.fingerprint(group, state));
- }
- else {
- key.append(QLatin1String("noeffect"));
- }
-
- return key;
-}
-
QImage KIconLoaderPrivate::createIconImage(const QString &path, int size)
{
// Use the extension as the format. Works for XPM and PNG, but not for SVG. The
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic