[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: Re: KDE/kdepim/plugins/kmail/bodypartformatter
From: David Faure <dfaure () kdab ! net>
Date: 2008-02-18 11:11:28
Message-ID: 200802181211.31982.dfaure () kdab ! net
[Download RAW message or body]
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 :-)
Oh well, no big deal, just a common misconception about QLatin1String IMHO.
--
David Faure, faure@kde.org, dfaure@klaralvdalens-datakonsult.se
KDE/KOffice developer, Qt consultancy projects
Klarälvdalens Datakonsult AB, Platform-independent software solutions
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic