[PATCH] Cache returned KIconLoader pixmaps in 4.5.2
Ingo Klöcker
kloecker at kde.org
Mon Sep 13 19:37:11 BST 2010
On Monday 13 September 2010, Torgny Nyblom wrote:
> On Mon, 13 Sep 2010 11:36:15 +0200
>
> Matthias Fuchs <mat69 at gmx.net> wrote:
> > I just realised that I sent an outdated patch, here is a newer one.
>
> [...]
>
> > @@ -756,26 +757,9 @@
> >
> > 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;
> > -
> > - if (group == KIconLoader::User) {
> > - key = QLatin1String("$kicou_");
> > - }
> > - else {
> > - key = QLatin1String("$kico_");
> > - }
> > -
> > -
> > key.append(QString("%1_%2_%3").arg(name).arg(size).arg(overlays.jo
> > in("_"))); -
> > - if (group >= 0) {
> > - key.append(mpEffect.fingerprint(group, state));
> > - }
> > - else {
> > - key.append(QLatin1String("noeffect"));
> > - }
> > -
> > - return key;
> > + return (group == KIconLoader::User ? QLatin1Literal("$kicou_")
> > : QLatin1Literal("$kico_")) % + name % QLatin1Char('_')
> > % QString::number(size) % QLatin1Char('_') % overlays.join("_") %
> > + (group >= 0 ? mpEffect.fingerprint(group, state) :
> > QString("noeffect"));//QString here, since ternary operator does
> > not support different classes
> >
> > }
> > QImage KIconLoaderPrivate::createIconImage(const QString &path,
> > int size)
>
> Sorry but do you really think this makes the code more readable?
Maybe not, but something like
QString("%1_%2_%3").arg(name).arg(size).arg(overlays.join("_"))
is completely braindead because it's horribly slow.
What about
return ( group == KIconLoader::User ? QLatin1Literal("$kicou_") : QLatin1Literal("$kico_") )
% name
% QLatin1Char('_')
% QString::number(size)
% QLatin1Char('_')
% overlays.join("_")
% ( group >= 0 ? mpEffect.fingerprint(group, state) : QString("noeffect") );
?
Regards,
Ingo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20100913/2e9fc034/attachment.sig>
More information about the kde-core-devel
mailing list