inefficient QString coding practice

Adriaan de Groot adridg at
Sun Mar 14 15:08:04 GMT 2004

On Sun, 14 Mar 2004, Simon Hausmann wrote:
> On Sunday 14 March 2004 15:34, Tobias Koenig wrote:
> > > Currently we have QString::fromLatin1(...). Is that better?
> >
> > No, and that's the only reason why I never use it ;)

#define CSL1(a) QString::fromLatin1(a "")

That's short for "const string latin 1" and all you can feed it are string
constants (the "" is a weird kind of check for that). Useful for marking
strings as such, and can be redefined (to just a) as needed. I use it all
the time, but then again, I use QT_NO_* as well, since I _need_ to be
picky about encodings in my app.

> Really, how often do you have to write it?
> QLatin1String is for corners in library development. Most of the time
> if ( bleh == "foo" ) doesn't really matter performance wise, in an
> application.

The original claim by Juergen was that bleh == "foo" incurs a considerable
malloc / free and whatnot overhead and that it should be kept in mind. As
long as there's no numbers attached, neither "doesn't really matter
performance-wise" or "is important" can be evaluated.

More information about the kde-core-devel mailing list