On Friday, 16 June 2017 16:35:54 PDT André Pönitz wrote:
> On Fri, Jun 16, 2017 at 12:52:24PM -0700, Thiago Macieira wrote:
> > Here's a tricky question: how do you create a QStringLiteral with
> > non-ASCII
> > characters that will work on all our supported compilers?
> 
> I don't have to, unless I have profiler supported evidence that
> it matters.

QStringLiteral is infinitely faster at runtime than QString::fromUtf8. It also 
occupies roughly 33% less memory than QString::fromUtf8 of a literal, as the 
latter needs the narrow character equivalent (read-only memory) plus the 
UTF-16 converted text (heap, which has overhead).

This is for a simple, static message. 

> In the common case where it does not matter, the string can be
> created at run time.

At a cost and overhead.

>     QSTRINGLITERAL('M', 0xf6, 0xf6, 0xf6, 'p', '!')
> 
> instead of
> 
>     QStringLiteral("Möööp!")

Yeah, no thanks.

The whole point is that we can do better. All we need to do is drop an old, 
buggy compiler.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to