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

2020-03-05 Thread Constantin Makshin
Every `arg(numeric_value)` overload uses a temporary `QString` object to build a text representation of `numeric_value` needed by the actual placeholder-replacement function. Even `arg(QChar)` and `arg(char)` create single-character `QString`s and pass them to either `arg(const QString&)` or

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

2020-03-05 Thread Elvis Stansvik
Den tors 5 mars 2020 kl 21:24 skrev Max Paperno : > > On 3/5/2020 3:11 PM, Elvis Stansvik wrote: > > Den tors 5 mars 2020 kl 19:26 skrev Max Paperno : > >> One thing for sure, since my benchmarks, from here on I will very much > >> prefer the "multiArg" version of .arg() vs. using multiple

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

2020-03-05 Thread Max Paperno
On 3/5/2020 3:11 PM, Elvis Stansvik wrote: Den tors 5 mars 2020 kl 19:26 skrev Max Paperno : 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

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

2020-03-05 Thread Elvis Stansvik
Den tors 5 mars 2020 kl 19:26 skrev Max Paperno : > > > 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,

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

2020-03-05 Thread Max Paperno
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()

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

2020-03-05 Thread Benjamin TERRIER
On Mon, 17 Feb 2020 at 05:33, Max Paperno wrote: > > Then found the [HEADS-UP: QStringLiteral][2] 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

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

2020-03-02 Thread Max Paperno
Well, not sure if my question was too vague, TL;DR, or just no one knows/cares to explain. So I created some benchmarks. Code and my results at: https://gist.github.com/mpaperno/e09d1c295eef94a45176c5cb2002a00e QStringLiteral().arg and .append() is consistently a little faster than QString()

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

2020-02-16 Thread Max Paperno
HI folks, I'm confused about a "best" way to use .arg() with fixed/static strings (not tr()). Or if it should be used at all, for that matter, in terms of efficiency. QStringLiteral seemed pretty good to me after reading several blog posts (from Marc Mutz, Kai Koehne, Olivier Goffart, among