[Development] HEADS-UP: QStringLiteral

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Wed Aug 21 12:53:02 CEST 2019


Hi,

On 21/08/2019 11:50, Bogdan Vatra via Development wrote:
> 
>    Personally I'm not going to waste my time learning 10 sting wrappers and
> classes just to make some pico optimizations like:
> 
> QString ext = QLatin1String("exe"); // it's terribly wrong and people which
> are doing this mistake must be stoned to death!
> 
> QString ext = QStringLiteral("exe"); // it's so good and it will save the
> planet from extinction!
> 
> // But
> QString ext1 = QLatin1String("exe") + ext; // it's ok
> // and
> QString ext = QStringLiteral("exe") + ext; // it's a abomination!
> 
> // Even more
> QHash<QString, QString> test;
> test[QLatin1String("key1")] = QLatin1String("some text %1").arg(1); // wrong
> test[QStringLiteral("key1")] = QStringLiteral("some text %1").arg(1); // wrong
> again
> test[QLatin1String("key1")] = QStringLiteral("some text %1").arg(1); // still
> wrong
> test[QLatin1String("key1")] = QStringLiteral("some text %1").arg(1); //
> victory !!!

How many of these are "mistakes" detectable by tooling? Because if they 
are, they're a very minor issue.

Thanks,
-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4329 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.qt-project.org/pipermail/development/attachments/20190821/25a666d8/attachment.bin>


More information about the Development mailing list