Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Create strings in one expression (saving mallocs thanks to QStringBuilder)

parent fd49ad51
......@@ -801,13 +801,11 @@ QString AbstractDeclarationNavigationContext::declarationSizeInformation(const D
const auto bitOffset = memberDecl->bitOffsetOf() % 8;
const QString byteOffsetStr = i18np("1 Byte", "%1 Bytes", byteOffset);
const QString bitOffsetStr = bitOffset ? i18np("1 Bit", "%1 Bits", bitOffset) : QString();
sizeInfo += i18n("offset in parent: %1", bitOffset ? i18nc("%1: bytes, %2: bits", "%1, %2", byteOffsetStr, bitOffsetStr) : byteOffsetStr);
sizeInfo += "; ";
sizeInfo += i18n("offset in parent: %1", bitOffset ? i18nc("%1: bytes, %2: bits", "%1, %2", byteOffsetStr, bitOffsetStr) : byteOffsetStr) + QLatin1String("; ");
}
if (memberDecl->sizeOf() >= 0) {
sizeInfo += i18n("size: %1 Bytes", memberDecl->sizeOf());
sizeInfo += "; ";
sizeInfo += i18n("size: %1 Bytes", memberDecl->sizeOf()) + QLatin1String("; ");
}
if (memberDecl->alignOf() >= 0) {
......
......@@ -253,7 +253,7 @@ void EnvironmentWidget::batchModeEditButtonClicked()
for (int i = 0; i < m_proxyModel->rowCount(); ++i) {
const auto variable = m_proxyModel->index(i, EnvironmentProfileModel::VariableColumn).data().toString();
const auto value = m_proxyModel->index(i, EnvironmentProfileModel::ValueColumn).data().toString();
text.append(QStringLiteral("%1=%2\n").arg(variable, value));
text.append(variable + QLatin1Char('=') + value + QLatin1Char('\n'));
}
edit->setPlainText(text);
layout->addWidget( edit );
......
......@@ -46,7 +46,7 @@ QByteArray preprocess(QByteArray json)
commentIndex = json.indexOf('#', commentIndex);
}
return json.prepend('{').append('}');
return '{' + json + '}';
}
DeclarationValidator::DeclarationValidator()
......
......@@ -142,9 +142,7 @@ namespace KDevelop
s << variant;
}
QString result = QStringLiteral("@Variant(");
result += QString::fromLatin1(a.constData(), a.size());
result += QLatin1Char(')');
QString result = QStringLiteral("@Variant(") + QString::fromLatin1(a.constData(), a.size()) + QLatin1Char(')');
return result;
}
......
......@@ -98,13 +98,10 @@ Path::Path(const QUrl& url)
if (!url.isLocalFile()) {
// handle remote urls
QString urlPrefix;
urlPrefix += url.scheme();
urlPrefix += QLatin1String("://");
QString urlPrefix = url.scheme() + QLatin1String("://");
const QString user = url.userName();
if (!user.isEmpty()) {
urlPrefix += user;
urlPrefix += QLatin1Char('@');
urlPrefix += user + QLatin1Char('@');
}
urlPrefix += url.host();
if (url.port() != -1) {
......
......@@ -877,8 +877,7 @@ ClangCodeCompletionContext::ClangCodeCompletionContext(const DUContextPointer& c
if (trimmedText.endsWith(QLatin1Char('.'))) {
// TODO: This shouldn't be needed if Clang provided diagnostic.
// But it doesn't always do it, so let's try to manually determine whether '.' is used instead of '->'
m_text = trimmedText.left(trimmedText.size() - 1);
m_text += QStringLiteral("->");
m_text = trimmedText.leftRef(trimmedText.size() - 1) + QStringLiteral("->");
CXUnsavedFile unsaved;
unsaved.Filename = file.constData();
......
......@@ -418,13 +418,12 @@ QString makeSignatureString(const KDevelop::Declaration* functionDecl, const Sig
// constructors don't have a return type
if (signature.returnType.isValid()) {
ret += CodegenHelper::simplifiedTypeString(signature.returnType.abstractType(),
visibilityFrom);
ret += QLatin1Char(' ');
visibilityFrom)
+ QLatin1Char(' ');
}
ret += editingDefinition ? functionDecl->qualifiedIdentifier().toString() : functionDecl->identifier().toString();
ret += QLatin1Char('(');
ret += (editingDefinition ? functionDecl->qualifiedIdentifier().toString() : functionDecl->identifier().toString())
+ QLatin1Char('(');
int pos = 0;
foreach(const ParameterItem &item, signature.parameters)
......
......@@ -106,7 +106,7 @@ ClangProblem::ClangProblem(CXDiagnostic diagnostic, CXTranslationUnit unit)
QString description = ClangString(clang_getDiagnosticSpelling(diagnostic)).toString();
if (!diagnosticOption.isEmpty()) {
description.append(QStringLiteral(" [%1]").arg(diagnosticOption));
description.append(QLatin1String(" [") + diagnosticOption + QLatin1Char(']'));
}
setDescription(prettyDiagnosticSpelling(description));
......
......@@ -93,8 +93,7 @@ QString strippedQid(const QualifiedIdentifier& qid)
}
const auto parts = qid.count();
for (int i = 0; i < parts - 1; ++i) {
result += qid.at(i).toString();
result += QLatin1String("::");
result += qid.at(i).toString() + QLatin1String("::");
}
const auto last = qid.at(parts - 1);
result += last.identifier().str();
......
......@@ -50,7 +50,6 @@ void UnsavedFile::convertToUtf8()
m_fileNameUtf8 = m_fileName.toUtf8();
m_contentsUtf8.clear();
foreach(const QString& line, m_contents) {
m_contentsUtf8 += line.toUtf8();
m_contentsUtf8 += '\n';
m_contentsUtf8 += line.toUtf8() + '\n';
}
}
......@@ -434,8 +434,7 @@ void MIDebugSession::debuggerStateChange(DBGStateFlags oldState, DBGStateFlags n
for (unsigned int i = 0; delta != 0 && i < 32; ++i) {
if (delta & (1 << i)) {
delta &= ~(1 << i);
out += ((1 << i) & newState) ? " +" : " -";
out += QString::number(i);
out += (((1 << i) & newState) ? " +" : " -") + QString::number(i);
}
}
}
......
......@@ -320,8 +320,7 @@ void IRegisterController::setStructuredRegister(const Register& reg, const Group
r.value = r.value.trimmed();
r.value.replace(' ', ',');
if (r.value.contains(',')) {
r.value.append('}');
r.value.prepend('{');
r.value = '{' + r.value + '}';
}
r.name += '.' + Converters::modeToString(m_formatsModes[group.index()].modes.first());
......
......@@ -185,7 +185,7 @@ QString Utils::quote(const QString& str, char quoteCh)
{
QString res = str;
res.replace(QLatin1Char('\\'), QLatin1String("\\\\")).replace(quoteCh, QStringLiteral("\\") + quoteCh);
return res.prepend(quoteCh).append(quoteCh);
return quoteCh + res + quoteCh;
}
QString Utils::unquote(const QString &str, bool unescapeUnicode, char quoteCh)
......
......@@ -1138,8 +1138,7 @@ void GitPlugin::parseGitLogOutput(DVcsJob * job)
item.addItem(itemEvent);
} else if (line.startsWith(QLatin1String(" "))) {
message += line.remove(0, 4);
message += '\n';
message += line.midRef(4) + QLatin1Char('\n');
}
}
......
......@@ -31,7 +31,7 @@ QString substitudePattern(const QString& pattern, const QString& searchString)
else if(ch == 's')
result.append(subst);
else
result.append('%').append(ch);
result.append(QLatin1Char('%') + ch);
}
else if(ch == '%')
expectEscape = true;
......
......@@ -44,13 +44,13 @@ Visualizer::Visualizer(const QString& resultsFile, QObject* parent)
this, [this](QProcess::ProcessError error) {
QString errorMessage;
if (error == QProcess::FailedToStart) {
errorMessage += i18n("Failed to start visualizer from \"%1\".", program());
errorMessage += QStringLiteral("\n\n");
errorMessage += i18n("Check your settings and install the visualizer if necessary.");
errorMessage = i18n("Failed to start visualizer from \"%1\".", program())
+ QStringLiteral("\n\n")
+ i18n("Check your settings and install the visualizer if necessary.");
} else {
errorMessage += i18n("Error during visualizer execution:");
errorMessage += QStringLiteral("\n\n");
errorMessage += errorString();
errorMessage = i18n("Error during visualizer execution:")
+ QStringLiteral("\n\n")
+ errorString();
}
KMessageBox::error(activeMainWindow(), errorMessage, i18n("Heaptrack Error"));
});
......
......@@ -140,8 +140,7 @@ void PatchHighlighter::showToolTipForMark(const QPoint& pos, KTextEditor::Moving
currentPos = markers[b]->offset();
}
html += string.mid( currentPos, string.length()-currentPos ).toHtmlEscaped();
html += QLatin1String("<br/>");
html += string.mid(currentPos, string.length()-currentPos).toHtmlEscaped() + QLatin1String("<br/>");
}
auto browser = new QTextBrowser;
......
......@@ -75,8 +75,7 @@ QString toRevisionName(const KDevelop::VcsRevision& rev, const QString& currentR
}
break;
case VcsRevision::GlobalNumber:
tmp.append("#");
tmp.append(rev.revisionValue().toString());
tmp.append(QLatin1Char('#') + rev.revisionValue().toString());
return tmp;
case VcsRevision::Date:
case VcsRevision::FileNumber:
......@@ -317,8 +316,7 @@ KDevelop::VcsJob* PerforcePlugin::diff(const QUrl& fileOrDirectory, const KDevel
switch (dstRevision.revisionType()) {
case VcsRevision::FileNumber:
case VcsRevision::GlobalNumber:
depotDstFileName.append("#");
depotDstFileName.append(dstRevision.prettyValue());
depotDstFileName.append(QLatin1Char('#') + dstRevision.prettyValue());
*job << m_perforceExecutable << "diff2" << "-u" << depotSrcFileName << depotDstFileName;
break;
case VcsRevision::Special:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment