Expensive QString = ""

stephane Petithomme kde-optimize@mail.kde.org
Wed, 12 Mar 2003 08:56:47 +0800


On Wednesday 12 March 2003 08:18, Alexander Kellett wrote:
> On Wed, Mar 12, 2003 at 01:02:25AM +0100, Andr? W?bbeking wrote:
> > I don't know, if QString = "" appears frequently in time critical code
> > (KHtml, KDE start up, KConfig, ...), but if you really need an empty
> > QString the better solution would be to use a static const QString like
> > QString::null.
>
> just fyi,
> (QString::null).isNull() != QString("").isNull())
> therefore, they can't just be randomly switched over.
> in fact i kind of dislike the use of a null string
> in place of an formally empty string, its just not
> explicit enough for my liking.

Hi

If the QString::null() string is an issue for exact replacement, why not
creating a 

static QString Empty = "";

(It can also be shared for all library, but I don't know regarding naming 
clash...). Best sould be to add it in QString itself!

that match your requirement. This one would gie exact same result and avoid 
constructing the object each time. Just a referenced pointer update, which is 
pretty fast.
stephane

>
> Alex
> _______________________________________________
> Kde-optimize mailing list
> Kde-optimize@mail.kde.org
> http://mail.kde.org/mailman/listinfo/kde-optimize