[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: [PATCH] Cache returned KIconLoader pixmaps in 4.5.2
From:       Ingo =?iso-8859-1?q?Kl=F6cker?= <kloecker () kde ! org>
Date:       2010-09-13 18:37:11
Message-ID: 201009132037.12504 () thufir ! ingo-kloecker ! de
[Download RAW message or body]


On Monday 13 September 2010, Torgny Nyblom wrote:
> On Mon, 13 Sep 2010 11:36:15 +0200
> 
> Matthias Fuchs <mat69@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

["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic