Use of QLatin1String instead of QStringLiteral
AbandonedPublic

Authored by laysrodrigues on Jun 10 2017, 4:41 PM.

Details

Summary

The use of QLatin1String is more optimized than
QStringLiteral.
This tip was given by Lamarque and the doc follows:
http://doc.qt.io/qt-5/qlatin1string.html#details

Signed-off-by: Lays Rodrigues <laysrodriguessilva@gmail.com>

Diff Detail

Repository
R232 AtCore
Branch
strings
Lint
No Linters Available
Unit
No Unit Test Coverage
laysrodrigues created this revision.Jun 10 2017, 4:41 PM

Change more files

patrickelectric requested changes to this revision.Jun 10 2017, 5:01 PM
patrickelectric added inline comments.
src/atcore.cpp
87

the operator+ don't have a overload to QString, moving to QLatin1String don't make sense.

435

in args we can use qbytearray and here qbytearrayliteral

src/plugins/aprinterplugin.cpp
32 ↗(On Diff #15336)

QLatin1String will be converted to QString in runtime, change it back to QStringLiteral.

38 ↗(On Diff #15336)

Same here..
Check all the changes, and only use QLatin with the ones that will not be converted to QString.

This revision now requires changes to proceed.Jun 10 2017, 5:01 PM
src/atcore.cpp
87

the operator+ don't have a overload to QString from QLatin1String, moving to QLatin1String don't make sense.

laysrodrigues marked 4 inline comments as done.Jun 11 2017, 3:34 PM

Updating the changes

laysrodrigues edited edge metadata.

Update patrick changes

laysrodrigues added inline comments.Jun 11 2017, 3:37 PM
src/atcore.cpp
435

use of QByteArray here is breaking the build.
/home/lays/programs/atcore/core/src/atcore.cpp:435: error: ‘QString::QString(const QByteArray&)’ is private within this context

args.append(QByteArrayLiteral("X0 "));
                                    ^

I moved back to QStringLiteral

Fix error using QByteArray

patrickelectric requested changes to this revision.Jun 11 2017, 3:48 PM
patrickelectric added inline comments.
src/atcore.cpp
384

remove don't have a overload to remove and QLatin1String..

src/atcore_default_folders.h.in
27 ↗(On Diff #15352)

Another case that need conversion to QString.. Please.. check the doc before performing such change :)

This revision now requires changes to proceed.Jun 11 2017, 3:48 PM
laysrodrigues edited edge metadata.

Update last patrick comments

I used search and replace in all files, didn't pay attention
to the details that you are highlighting. =/

rizzitello edited edge metadata.Jun 13 2017, 1:46 PM

Possibly more places to revert, anywhere it will be cast as QString QStringLiteral should be used.

src/atcore_default_folders.h.in
29 ↗(On Diff #15422)

QStringList, revert to QStringLiteral

src/gcodecommands.cpp
94 ↗(On Diff #15422)

Function returns QString, revert the returns to QStringLiteral

130 ↗(On Diff #15422)

Function Returns QString , revert to QStringLiteral

src/seriallayer.cpp
34 ↗(On Diff #15422)

QStringlist , revert to QStringLiteral

rizzitello requested changes to this revision.Jun 13 2017, 1:47 PM
This revision now requires changes to proceed.Jun 13 2017, 1:47 PM
laysrodrigues edited edge metadata.

More fixes

patrickelectric requested changes to this revision.Jun 13 2017, 4:09 PM
patrickelectric added inline comments.
src/temperature.cpp
92

Again... Check if the class accept QLatin1String.
Not for only this line, but for the entire diff.

This revision now requires changes to proceed.Jun 13 2017, 4:09 PM
laysrodrigues abandoned this revision.Oct 31 2017, 11:25 AM