Tools: replace QString::trimmed() with QStringRef::trimmed()

... where it's possible. Reduce allocations.

Change-Id: I9908d9d65177d116a8a54146274a74edb801543e
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
bb10
Anton Kudryavtsev 2016-07-05 16:30:13 +03:00
parent 5392259ce6
commit 3a33ee78c9
2 changed files with 3 additions and 6 deletions

View File

@ -291,9 +291,8 @@ void WriteIncludes::writeHeaders(const OrderedSet &headers, bool global)
const StringMap::const_iterator hit = m_oldHeaderToNewHeader.constFind(sit.key());
const bool mapped = hit != m_oldHeaderToNewHeader.constEnd();
const QString header = mapped ? hit.value() : sit.key();
if (!header.trimmed().isEmpty()) {
if (!QStringRef(&header).trimmed().isEmpty())
m_output << "#include " << openingQuote << header << closingQuote << QLatin1Char('\n');
}
}
}

View File

@ -2473,10 +2473,8 @@ void WriteInitialization::acceptWidgetScripts(const DomScripts &widgetScripts, D
QString script;
for (const DomScript *domScript : qAsConst(scripts)) {
const QString snippet = domScript->text();
if (!snippet.isEmpty()) {
script += snippet.trimmed();
script += QLatin1Char('\n');
}
if (!snippet.isEmpty())
script += QStringRef(&snippet).trimmed() + QLatin1Char('\n');
}
if (script.isEmpty())
return;