Reduce usage of QStringRef::toString() in the core plugin.

Change-Id: Ic3e2c16f5345012b8c6654929deb74f753e3ec8f
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
Friedemann Kleint
2013-08-29 11:03:13 +02:00
committed by hjk
parent 84cfc4f914
commit bf5e8dc0e7
2 changed files with 10 additions and 10 deletions

View File

@@ -327,7 +327,7 @@ static void localizedText(const QStringList &locales, QXmlStreamReader *reader,
static bool parseOutputAttribute(const QString &attribute, QXmlStreamReader *reader, ExternalTool::OutputHandling *value) static bool parseOutputAttribute(const QString &attribute, QXmlStreamReader *reader, ExternalTool::OutputHandling *value)
{ {
const QString output = reader->attributes().value(attribute).toString(); const QStringRef output = reader->attributes().value(attribute);
if (output == QLatin1String(kOutputShowInPane)) { if (output == QLatin1String(kOutputShowInPane)) {
*value = ExternalTool::ShowInPane; *value = ExternalTool::ShowInPane;
} else if (output == QLatin1String(kOutputReplaceSelection)) { } else if (output == QLatin1String(kOutputReplaceSelection)) {
@@ -381,7 +381,7 @@ ExternalTool * ExternalTool::createFromXml(const QByteArray &xml, QString *error
break; break;
} }
if (reader.attributes().hasAttribute(QLatin1String(kModifiesDocument))) { if (reader.attributes().hasAttribute(QLatin1String(kModifiesDocument))) {
const QString &value = reader.attributes().value(QLatin1String(kModifiesDocument)).toString(); const QStringRef value = reader.attributes().value(QLatin1String(kModifiesDocument));
if (value == QLatin1String(kYes) || value == QLatin1String(kTrue)) { if (value == QLatin1String(kYes) || value == QLatin1String(kTrue)) {
tool->m_modifiesCurrentDocument = true; tool->m_modifiesCurrentDocument = true;
} else if (value == QLatin1String(kNo) || value == QLatin1String(kFalse)) { } else if (value == QLatin1String(kNo) || value == QLatin1String(kFalse)) {

View File

@@ -1043,7 +1043,7 @@ static bool addMagicMatchRule(const QXmlStreamAttributes &atts,
const MagicRuleMatcherPtr &ruleMatcher, const MagicRuleMatcherPtr &ruleMatcher,
QString *errorMessage) QString *errorMessage)
{ {
const QString type = atts.value(QLatin1String(matchTypeAttributeC)).toString(); const QStringRef type = atts.value(QLatin1String(matchTypeAttributeC));
if (type != QLatin1String(matchStringTypeValueC) && if (type != QLatin1String(matchStringTypeValueC) &&
type != QLatin1String(matchByteTypeValueC)) { type != QLatin1String(matchByteTypeValueC)) {
qWarning("%s: match type %s is not supported.", Q_FUNC_INFO, type.toUtf8().constData()); qWarning("%s: match type %s is not supported.", Q_FUNC_INFO, type.toUtf8().constData());
@@ -1105,25 +1105,25 @@ bool BaseMimeTypeParser::parse(QIODevice *dev, const QString &fileName, QString
break; break;
case ParseComment: { case ParseComment: {
// comments have locale attributes. We want the default, English one // comments have locale attributes. We want the default, English one
QString locale = atts.value(QLatin1String(localeAttributeC)).toString(); const QStringRef locale = atts.value(QLatin1String(localeAttributeC));
const QString comment = QCoreApplication::translate("MimeType", reader.readElementText().toLatin1()); const QString comment = QCoreApplication::translate("MimeType", reader.readElementText().toLatin1());
if (locale.isEmpty()) if (locale.isEmpty())
data.comment = comment; data.comment = comment;
else else
data.localeComments.insert(locale, comment); data.localeComments.insert(locale.toString(), comment);
} }
break; break;
case ParseAlias: { case ParseAlias: {
const QString alias = atts.value(QLatin1String(mimeTypeAttributeC)).toString(); const QStringRef alias = atts.value(QLatin1String(mimeTypeAttributeC));
if (!alias.isEmpty()) if (!alias.isEmpty())
data.aliases.push_back(alias); data.aliases.push_back(alias.toString());
} }
break; break;
case ParseMagic: { case ParseMagic: {
int priority = 0; int priority = 0;
const QString priorityS = atts.value(QLatin1String(priorityAttributeC)).toString(); const QStringRef priorityS = atts.value(QLatin1String(priorityAttributeC));
if (!priorityS.isEmpty()) { if (!priorityS.isEmpty()) {
if (!parseNumber(priorityS, &priority, errorMessage)) if (!parseNumber(priorityS.toString(), &priority, errorMessage))
return false; return false;
} }
@@ -1694,7 +1694,7 @@ QList<MimeType> MimeDatabasePrivate::readUserModifiedMimeTypes()
mimeType.setGlobPatterns(toGlobPatterns(patterns.split(kSemiColon))); mimeType.setGlobPatterns(toGlobPatterns(patterns.split(kSemiColon)));
} else if (reader.name() == QLatin1String(matchTagC)) { } else if (reader.name() == QLatin1String(matchTagC)) {
const QString &value = atts.value(matchValueAttribute).toString(); const QString &value = atts.value(matchValueAttribute).toString();
const QString &type = atts.value(matchTypeAttribute).toString(); const QStringRef type = atts.value(matchTypeAttribute);
const QString &offset = atts.value(matchOffsetAttribute).toString(); const QString &offset = atts.value(matchOffsetAttribute).toString();
QPair<int, int> range = MagicRule::fromOffset(offset); QPair<int, int> range = MagicRule::fromOffset(offset);
const int priority = atts.value(priorityAttribute).toString().toInt(); const int priority = atts.value(priorityAttribute).toString().toInt();