Optimization. Move literals.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-04-13 09:00:09 +03:00
parent 2a3948c549
commit 1e5ee0ab8b
9 changed files with 16 additions and 20 deletions

View file

@ -1635,11 +1635,11 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
element = createElement(TagGradation);
QDomElement heights = createElement(TagHeights);
heights.setAttribute(AttrAll, QLatin1String("true"));
heights.setAttribute(AttrAll, trueStr);
element.appendChild(heights);
QDomElement sizes = createElement(TagSizes);
sizes.setAttribute(AttrAll, QLatin1String("true"));
sizes.setAttribute(AttrAll, trueStr);
element.appendChild(sizes);
break;
}

View file

@ -376,10 +376,7 @@ bool VDomDocument::GetParametrBool(const QDomElement &domElement, const QString
{
parametr = GetParametrString(domElement, name, defValue);
const QStringList bools = QStringList() << QLatin1String("true")
<< QLatin1String("false")
<< QChar('1')
<< QChar('0');
const QStringList bools {trueStr, falseStr, QChar('1'), QChar('0')};
switch (bools.indexOf(parametr))
{
case 0: // true

View file

@ -167,7 +167,7 @@ void VVITConverter::AddNewTagsForV0_3_0()
QDomNode refChild = rootElement.firstChildElement("version");
QDomElement ro = createElement(QStringLiteral("read-only"));
const QDomText roNodeText = createTextNode("false");
const QDomText roNodeText = createTextNode(falseStr);
ro.appendChild(roNodeText);
refChild = rootElement.insertAfter(ro, refChild);

View file

@ -162,7 +162,7 @@ void VVSTConverter::AddNewTagsForV0_4_0()
{
QDomElement ro = createElement(QStringLiteral("read-only"));
const QDomText roNodeText = createTextNode("false");
const QDomText roNodeText = createTextNode(falseStr);
ro.appendChild(roNodeText);
refChild = rootElement.insertAfter(ro, refChild);
}

View file

@ -695,7 +695,7 @@ void VMeasurements::CreateEmptyMultisizeFile(Unit unit, int baseSize, int baseHe
mElement.appendChild(version);
QDomElement ro = createElement(TagReadOnly);
const QDomText roNodeText = createTextNode("false");
const QDomText roNodeText = createTextNode(falseStr);
ro.appendChild(roNodeText);
mElement.appendChild(ro);
@ -738,7 +738,7 @@ void VMeasurements::CreateEmptyIndividualFile(Unit unit)
mElement.appendChild(version);
QDomElement ro = createElement(TagReadOnly);
const QDomText roNodeText = createTextNode("false");
const QDomText roNodeText = createTextNode(falseStr);
ro.appendChild(roNodeText);
mElement.appendChild(ro);

View file

@ -197,12 +197,6 @@ const QStringList labelTemplatePlaceholders = QStringList() << pl_size
const QString cursorArrowOpenHand = QStringLiteral("://cursor/cursor-arrow-openhand.png");
const QString cursorArrowCloseHand = QStringLiteral("://cursor/cursor-arrow-closehand.png");
// From documantation: If you use QStringLiteral you should avoid declaring the same literal in multiple places: This
// furthermore blows up the binary sizes.
const QString degreeSymbol = QStringLiteral("°");
const QString trueStr = QStringLiteral("true");
const QString falseStr = QStringLiteral("false");
const QString unitMM = QStringLiteral("mm");
const QString unitCM = QStringLiteral("cm");
const QString unitINCH = QStringLiteral("inch");

View file

@ -397,10 +397,6 @@ extern const QStringList labelTemplatePlaceholders;
extern const QString cursorArrowOpenHand;
extern const QString cursorArrowCloseHand;
extern const QString degreeSymbol;
extern const QString trueStr;
extern const QString falseStr;
extern const QString strOne;
extern const QString strTwo;
extern const QString strThree;

View file

@ -31,3 +31,6 @@ const QString LONG_OPTION_NO_HDPI_SCALING = QStringLiteral("no-scaling");
const QString editDeleteIcon = QStringLiteral("edit-delete");
const QString preferencesOtherIcon = QStringLiteral("preferences-other");
const QString degreeSymbol = QStringLiteral("°");
const QString trueStr = QStringLiteral("true");
const QString falseStr = QStringLiteral("false");

View file

@ -30,9 +30,15 @@
#include <QString>
// From documantation: If you use QStringLiteral you should avoid declaring the same literal in multiple places: This
// furthermore blows up the binary sizes.
extern const QString LONG_OPTION_NO_HDPI_SCALING;
extern const QString editDeleteIcon;
extern const QString preferencesOtherIcon;
extern const QString degreeSymbol;
extern const QString trueStr;
extern const QString falseStr;
#endif // LITERALS_H