Re: Roll our own qUtf8Printable()?

2018-02-26 Thread Lubomir I. Ivanov
On 26 February 2018 at 11:35, Berthold Stoeger wrote: > On Montag, 26. Februar 2018 10:04:23 CET Lubomir I. Ivanov wrote: >> On 26 February 2018 at 08:49, Berthold Stoeger >> >> wrote: >> > On Montag, 26. Februar 2018 02:33:58 CET Thiago

Re: Roll our own qUtf8Printable()?

2018-02-26 Thread Berthold Stoeger
On Montag, 26. Februar 2018 10:04:23 CET Lubomir I. Ivanov wrote: > On 26 February 2018 at 08:49, Berthold Stoeger > > wrote: > > On Montag, 26. Februar 2018 02:33:58 CET Thiago Macieira wrote: > >> > [Sidenote: There's a reason the C++-standard disallows reference >

Re: Roll our own qUtf8Printable()?

2018-02-26 Thread Lubomir I. Ivanov
On 26 February 2018 at 08:49, Berthold Stoeger wrote: > On Montag, 26. Februar 2018 02:33:58 CET Thiago Macieira wrote: > >> > [Sidenote: There's a reason the C++-standard disallows reference counting >> > for its string class.] >> >> There is, but this isn't it. The

Re: Roll our own qUtf8Printable()?

2018-02-25 Thread Berthold Stoeger
On Montag, 26. Februar 2018 02:33:58 CET Thiago Macieira wrote: > > [Sidenote: There's a reason the C++-standard disallows reference counting > > for its string class.] > > There is, but this isn't it. The concern is the unexpected memory allocation > when calling a non-const function. The

Re: Roll our own qUtf8Printable()?

2018-02-25 Thread Berthold Stoeger
On Montag, 26. Februar 2018 03:19:48 CET Thiago Macieira wrote: > On domingo, 25 de fevereiro de 2018 17:13:11 PST Thiago Macieira wrote: > > But there's another option, which is to avoid a copy of the QString if the > > input is already a QString. Let me try a few variations of possible > >

Re: Roll our own qUtf8Printable()?

2018-02-25 Thread Berthold Stoeger
On Montag, 26. Februar 2018 02:13:11 CET Thiago Macieira wrote: > On domingo, 25 de fevereiro de 2018 15:00:38 PST Lubomir I. Ivanov wrote: > > wrote: > > > Dear all, > suggested here: > > > So what do you think about rolling our own helper function: > > > > > >

Re: Roll our own qUtf8Printable()?

2018-02-25 Thread Thiago Macieira
On domingo, 25 de fevereiro de 2018 17:13:11 PST Thiago Macieira wrote: > But there's another option, which is to avoid a copy of the QString if the > input is already a QString. Let me try a few variations of possible > solutions and compile Qt to see what happens. > > I'll BRB. Change to Qt:

Re: Roll our own qUtf8Printable()?

2018-02-25 Thread Thiago Macieira
On domingo, 25 de fevereiro de 2018 14:34:28 PST Berthold Stoeger wrote: > I think the compiler can't optimize the copy away, because QString doesn't > copy the string, but does reference counting. I'm not sure if it is allowed > to throw away the side effects of the ref()/deref() calls? This does

Re: Roll our own qUtf8Printable()?

2018-02-25 Thread Thiago Macieira
On domingo, 25 de fevereiro de 2018 15:00:38 PST Lubomir I. Ivanov wrote: > wrote: > > Dear all, > > > > In many places, QStrings are converted to C-style strings with an > > expression of the kind > > > > s.toUf8().data() > > > > I have a patch replacing all of

Re: Roll our own qUtf8Printable()?

2018-02-25 Thread Lubomir I. Ivanov
On 25 February 2018 at 21:39, Berthold Stoeger wrote: > Dear all, > > In many places, QStrings are converted to C-style strings with an expression > of the kind > s.toUf8().data() > > I have a patch replacing all of them with > qUtf8Printable(s) > > The idea is that

Re: Roll our own qUtf8Printable()?

2018-02-25 Thread Berthold Stoeger
Hi, On Sonntag, 25. Februar 2018 22:40:00 CET Lubomir I. Ivanov wrote: > On 25 February 2018 at 21:39, Berthold Stoeger > > wrote: > > Dear all, > > Much to my surprise, qUtf8Printable() produced larger code. The reason is > > that it is defined as a macro in : > >

Re: Roll our own qUtf8Printable()?

2018-02-25 Thread Lubomir I. Ivanov
On 25 February 2018 at 23:40, Lubomir I. Ivanov wrote: > On 25 February 2018 at 21:39, Berthold Stoeger > wrote: >> Dear all, >> >> In many places, QStrings are converted to C-style strings with an expression >> of the kind >> s.toUf8().data() >>

Re: Roll our own qUtf8Printable()?

2018-02-25 Thread Lubomir I. Ivanov
On 25 February 2018 at 21:39, Berthold Stoeger wrote: > Dear all, > > In many places, QStrings are converted to C-style strings with an expression > of the kind > s.toUf8().data() > > I have a patch replacing all of them with > qUtf8Printable(s) > > The idea is that

Roll our own qUtf8Printable()?

2018-02-25 Thread Berthold Stoeger
Dear all, In many places, QStrings are converted to C-style strings with an expression of the kind s.toUf8().data() I have a patch replacing all of them with qUtf8Printable(s) The idea is that - according to the documentation - this is equivalent to s.toUtf8().constData() The latter should