[Interest] Building strings with .arg() (arrrgh)
b.terrier at gmail.com
Thu Mar 5 16:20:46 CET 2020
On Mon, 17 Feb 2020 at 05:33, Max Paperno <max-l at wdg.us> wrote:
> Then found the [HEADS-UP: QStringLiteral] post by Marc on the
> development list and didn't feel so good about it anymore. Specifically
> where he says that using it with .arg() is an "anti-pattern" but not in
> any way that I can understand (vs. just using QString). I went through
> that whole meandering thread but didn't see string builder stuff brought
> up again.
I believe Marc was saying that using QStringLiteral *inside* a .arg() call
is an anti-pattern,
and not that using .arg() *on* a QStringLiteral is one.
This match the documentation that states " QLatin1String can still be more
efficient than QStringLiteral
when the string is passed to a function that has an overload taking
QLatin1String and this overload
avoids conversion to QString."
And the fact that QString::arg() does have an overload for QLatin1String.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest