question regarding QLatin1String and QLatin1Char

Evan Teran evan.teran at gmail.com
Mon Aug 6 21:43:28 UTC 2012


I've been working on a fairly large improvement to kcalc. Specifically a
much improved knumber library which will eventually bring arbitrary
precision trig functions :-).

Anyway, looking throughout the code, I see a LOT of usage of QLatin1String
and QLatin1Char and I'm not 100% sure what the benefit is.

>From the documentation is looks as though it's primary usage is to be able
to specify string constants without needed to create a full QString object.
here's my question, if that constant is going to become a QString anyway,
is there any benefit? For example:

// does this make sense?
QString func() {
    return QLatin1String("Hello world");
}

The documentation is even more vague about the benefits of QLatin1Char, it
says it used to avoid codec stuff, which I highly doubt is being used in
kcalc. So can I expect there to be any benefit?

Unfortunately while it is used in a lot of places, the usage isn't 100%
consistant, based on the fact that things seem to work, I'm not sure what
improvement it is offering.

What do you guys think?

Evan Teran
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-utils-devel/attachments/20120806/4a0bfe79/attachment.html>


More information about the Kde-utils-devel mailing list