From ee35bdce8f6b08922b4c9e0c0c838e5f2c4a79ad Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Mon, 22 Feb 2021 22:38:43 +0200 Subject: Optimise string operations a bit - Use QString::arg(Args...) instead of .arg().arg() - Use QLatin1String for string comparisons, should be faster - Use QLatin1String::arg() for better readability - Add the comment dfaure suggested in the MR, to explain why it's '2%' then '%1' in a QString().arg().arg() NO_CHANGELOG --- src/gui/kconfiggroupgui.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/gui/kconfiggroupgui.cpp') diff --git a/src/gui/kconfiggroupgui.cpp b/src/gui/kconfiggroupgui.cpp index 09c31590..ab0c268f 100644 --- a/src/gui/kconfiggroupgui.cpp +++ b/src/gui/kconfiggroupgui.cpp @@ -54,8 +54,9 @@ static bool readEntryGui(const QByteArray &data, const char *key, const QVariant const int count = list.count(); if (count != 3 && count != 4) { - const QString formatError = QStringLiteral(" (wrong format: expected '%1' items, read '%2')"); - qCritical() << qPrintable(errString()) << qPrintable(formatError.arg(QStringLiteral("3' or '4")).arg(count)); + qCritical() // + << qPrintable(errString()) // + << qPrintable(QStringLiteral(" (wrong format: expected '%1' items, read '%2')").arg(QStringLiteral("3' or '4")).arg(count)); return true; // return default } @@ -70,9 +71,10 @@ static bool readEntryGui(const QByteArray &data, const char *key, const QVariant } if (j < 0 || j > 255) { static const char *const components[] = {"red", "green", "blue", "alpha"}; - const QString boundsError = QStringLiteral(" (bounds error: %1 component %2)"); qCritical() << qPrintable(errString()) - << qPrintable(boundsError.arg(QLatin1String(components[i])).arg(j < 0 ? QStringLiteral("< 0") : QStringLiteral("> 255"))); + << qPrintable(QStringLiteral(" (bounds error: %1 component %2)") + .arg(QLatin1String(components[i]), // + j < 0 ? QStringLiteral("< 0") : QStringLiteral("> 255"))); return true; // return default } } -- cgit v1.2.1