comments on KDE performance tips
Simon Hausmann
kde-optimize@mail.kde.org
Sat, 18 Jan 2003 11:13:06 +0100
On Sat, Jan 18, 2003 at 02:16:42AM +0100, Roger Larsson wrote:
> Note: there will be only one string constant "hallo" stored in the program
> due to g++ option '-fmerge-constants' (default with -O2)
> That is why we have QConstString, as a bonus space is saved and that
> reduces time too. Less cache/pages misses.
> if (QConstString("hallo") == QConstString("hallo")) ...
> // cheap constructors, no copy, comp ares only string storage location,
> // cheap destructors
>
> const QConstString bye = "bye"; // cheap constructor with no copy
> if (bye == bye) ... // only compares string storage location
Neither of these two QConstString usages do work nor are they
intended to work, because it expects raw QChar data and does not
provide a == operator because it privately inherits from QString.
If you operate on a raw array of QChar data like this you could use
it:
QChar *blah = ...
uint blahLength = ...
QChar *blubb = ...
uint blubbLength = ...
if ( QConstString( blah, blahLength ).string() ==
QConstString( blubb, blubbLength ).string() ) {
But this is equal to a pointer comparison, except that it's slower,
for the temporary objects being created.
Simon