inefficient QString coding practice

Simon Hausmann hausmann at kde.org
Sun Mar 14 14:45:24 GMT 2004


On Sunday 14 March 2004 15:34, Tobias Koenig wrote:
> > > > if(str == QLatin1String("foo")) { ... }
> > >
> > > Hmm, and you think the lazy developer will type 'QLatin1String' for
> > > every short "foobar" string?!?
> > > Can't we use a shorter name? Such a long name disturbs the whole code
> > > layout.
> >
> > Currently we have QString::fromLatin1(...). Is that better?
>
> No, and that's the only reason why I never use it ;)
>
> > You can always use a typedef if you think the length is really
> > disturbing. I still prefer long but descriptive names to short but
> > unclear ones.
>
> me too, but not when you have to write it that often like this one.

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.

Simon




More information about the kde-core-devel mailing list