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

List:       kde-commits
Subject:    Re: KDE/kdepim/plugins/kmail/bodypartformatter
From:       Ingo =?iso-8859-15?q?Kl=F6cker?= <kloecker () kde ! org>
Date:       2008-02-18 22:19:58
Message-ID: 200802182320.00165 () erwin ! ingo-kloecker ! de
[Download RAW message or body]


On Monday 18 February 2008, David Faure wrote:
> On Sunday 17 February 2008, Ingo Klöcker wrote:
> > On Saturday 16 February 2008, Till Adam wrote:
> > > +      const QString addedLineStyle( "style=\"" "color: green;\""
> > > );
> >
> > Why is this a QString while everything else is a QLatin1String?
> >
> > And wouldn't it make sense to make those static const so that they
> > are constructed only once? I guess it doesn't really matter because
> > the c'tor of QLatin1String is dead-cheap, but it might serve as
> > example for other usages of constants.
>
> This looks like funny optimization "lookalike" to me.
>
> text_xdiff.cpp:      static const QLatin1String tableStyle(
> Very fast, whether static or not.
>
> text_xdiff.cpp:      html += "<pre " + tableStyle + '>';
> Slow anyway, has to convert the QLatin1String to a QString at that
> point.
>
> QLatin1String saves you time only when you are comparing with it, not
> when you are going to assign from it...
>
> All those strings are used only once so it doesn't matter, but if
> they were used more than once then making them QString in the first
> place would actually be faster :-)

Well, they are used only once per call of format(). But it's true that 
it doesn't matter that much. On the other hand, if using QLatin1String 
gives a bad example (and the diff-bodypartformatter could serve as 
example for other bodypartformatters because it's so simple), then we 
should probably change the QLatin1Strings to QStrings again.


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