ClangCodemodel: Avoid repeated construction of category prefixes

Change-Id: I0166010a17f1f37855862f28cc9e2472b638c9de
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2022-08-03 14:27:18 +02:00
parent 057bb3095b
commit 8ae55344de

View File

@@ -76,15 +76,14 @@ QString diagnosticCategoryPrefixRemoved(const QString &text)
// Prefixes are taken from $LLVM_SOURCE_DIR/tools/clang/lib/Frontend/TextDiagnostic.cpp,
// function TextDiagnostic::printDiagnosticLevel (llvm-3.6.2).
static const QStringList categoryPrefixes = {
QStringLiteral("note"),
QStringLiteral("remark"),
QStringLiteral("warning"),
QStringLiteral("error"),
QStringLiteral("fatal error")
QStringLiteral("note: "),
QStringLiteral("remark: "),
QStringLiteral("warning: "),
QStringLiteral("error: "),
QStringLiteral("fatal error: ")
};
for (const QString &prefix : categoryPrefixes) {
const QString fullPrefix = prefix + QStringLiteral(": ");
for (const QString &fullPrefix : categoryPrefixes) {
if (theText.startsWith(fullPrefix)) {
theText.remove(0, fullPrefix.length());
return theText;