summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-02-23 22:01:52 +0100
committerMarc Mutz <marc.mutz@kdab.com>2016-02-24 17:14:20 +0000
commita4dee8e274f00a65bdd3ad706db6c39d4a82759d (patch)
tree23acc263877e70f9bf37e0678ae179dec8f0f8f7 /src/corelib
parent71b106ab436f75d3467a71b1b3739ce570b62522 (diff)
QMimeTypeParser: use QStringBuilder more
Replace QString::arg() with QStringBuilder, use QStringLiteral where appropriate, and remove it where it isn't (e.g. in QStringBuilder expressions). Saves ~750b in text size on optimized GCC 5.3 Linux AMD64 builds. Change-Id: I2471c849db79f477677213f9a155053248800590 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/mimetypes/qmimemagicrule.cpp13
-rw-r--r--src/corelib/mimetypes/qmimetypeparser.cpp5
2 files changed, 7 insertions, 11 deletions
diff --git a/src/corelib/mimetypes/qmimemagicrule.cpp b/src/corelib/mimetypes/qmimemagicrule.cpp
index 06628fa323..528dca3ff5 100644
--- a/src/corelib/mimetypes/qmimemagicrule.cpp
+++ b/src/corelib/mimetypes/qmimemagicrule.cpp
@@ -234,7 +234,7 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
m_matchFunction(nullptr)
{
if (m_type == Invalid)
- *errorString = QStringLiteral("Type %s is not supported").arg(type);
+ *errorString = QLatin1String("Type ") + type + QLatin1String(" is not supported");
// Parse for offset as "1" or "1:10"
const int colonIndex = offsets.indexOf(QLatin1Char(':'));
@@ -249,7 +249,7 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
if (m_value.isEmpty()) {
m_type = Invalid;
if (errorString)
- *errorString = QLatin1String("Invalid empty magic rule value");
+ *errorString = QStringLiteral("Invalid empty magic rule value");
return;
}
@@ -259,8 +259,7 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
if (!ok) {
m_type = Invalid;
if (errorString)
- *errorString = QString::fromLatin1("Invalid magic rule value \"%1\"").arg(
- QString::fromLatin1(m_value));
+ *errorString = QLatin1String("Invalid magic rule value \"") + QLatin1String(m_value) + QLatin1Char('"');
return;
}
m_numberMask = !m_mask.isEmpty() ? m_mask.toUInt(&ok, 0) : 0; // autodetect base
@@ -274,8 +273,7 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
if (m_mask.size() < 4 || !m_mask.startsWith("0x")) {
m_type = Invalid;
if (errorString)
- *errorString = QString::fromLatin1("Invalid magic rule mask \"%1\"").arg(
- QString::fromLatin1(m_mask));
+ *errorString = QLatin1String("Invalid magic rule mask \"") + QLatin1String(m_mask) + QLatin1Char('"');
return;
}
const QByteArray &tempMask = QByteArray::fromHex(QByteArray::fromRawData(
@@ -283,8 +281,7 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
if (tempMask.size() != m_pattern.size()) {
m_type = Invalid;
if (errorString)
- *errorString = QString::fromLatin1("Invalid magic rule mask size \"%1\"").arg(
- QString::fromLatin1(m_mask));
+ *errorString = QLatin1String("Invalid magic rule mask size \"") + QLatin1String(m_mask) + QLatin1Char('"');
return;
}
m_mask = tempMask;
diff --git a/src/corelib/mimetypes/qmimetypeparser.cpp b/src/corelib/mimetypes/qmimetypeparser.cpp
index b0d599fb0e..0751c1feed 100644
--- a/src/corelib/mimetypes/qmimetypeparser.cpp
+++ b/src/corelib/mimetypes/qmimetypeparser.cpp
@@ -205,7 +205,7 @@ bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
case ParseMimeType: { // start parsing a MIME type name
const QString name = atts.value(QLatin1String(mimeTypeAttributeC)).toString();
if (name.isEmpty()) {
- reader.raiseError(QString::fromLatin1("Missing '%1'-attribute").arg(QString::fromLatin1(mimeTypeAttributeC)));
+ reader.raiseError(QStringLiteral("Missing 'type'-attribute"));
} else {
data.name = name;
}
@@ -282,8 +282,7 @@ bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
break;
}
case ParseError:
- reader.raiseError(QString::fromLatin1("Unexpected element <%1>").
- arg(reader.name().toString()));
+ reader.raiseError(QLatin1String("Unexpected element <") + reader.name() + QLatin1Char('>'));
break;
default:
break;