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

Elvis Stansvik elvstone at gmail.com
Thu Mar 5 21:11:47 CET 2020


Den tors 5 mars 2020 kl 19:26 skrev Max Paperno <max-l at wdg.us>:
>
>
> 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.

Closing side note: There's a a nice Clazy diagnostic for that.

Cheers,
Elvis

>
> Anyway, thanks for pointing that out.
>
> Cheers,
> -Max
>
>
> [1]:
> https://lists.qt-project.org/pipermail/development/2019-August/037145.html
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest


More information about the Interest mailing list