[Interest] Building strings with .arg() (arrrgh)

Max Paperno max-l at wdg.us
Thu Mar 5 19:25:27 CET 2020


On 3/5/2020 10:20 AM, Benjamin TERRIER wrote:
> 
> 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.
> 

Hmmm, good point, indeed it could be read that way. There are two 
references to .arg() being available "on" (which I read as "for use 
with") QL1S that make me wonder and probably why I originally read it 
the other way.

 From that e-mail[1]:

"composition (QStringBuilder, append, prepend, arg() (now partly
available on QStringView and QLatin1String, too)"

and

"arg(string, ...., string) ("multiArg") is available now on QL1S and
QStringView"

Since QL1S has already been available in the .arg() overload since 5.10 
but QL1S.arg() is newer.

(Strangely there's no .arg(const char *) even though there's an 
append(const char *).)

One thing for sure, since my benchmarks, from here on I will very much 
prefer the "multiArg" version of .arg() vs. using multiple .arg()s.

Anyway, thanks for pointing that out.

Cheers,
-Max


[1]: 
https://lists.qt-project.org/pipermail/development/2019-August/037145.html


More information about the Interest mailing list