From dc878289c01011c59615746655b4e78d4bc90b91 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Wed, 3 Feb 2021 15:28:38 +0200 Subject: Minor code optimisations - Use a global var for a QString that's used many times - Break up long-all-cap variable names, it makes it harder to read (and I've fixed one typo in one of those ALLCAPS) - Fix some clazy warnings, make global QString objects in unit tests static (so that the compiler doesn't create symbols for them, it doesn't matter in a unit test but KF code acts as a reference sometimes that others copy from, tip from dfaure) - Add TODO note about changing kconfig_compiler to generate C++ code that uses multi-arg QString::arg(QString, QString, QString) instead of QString::arg().arg() - More const; more QString::at() instead of operator[] where appropriate - Use a ternary where it makes the code more readable (and uses less lines :)) NO_CHANGELOG --- autotests/kconfigloadertest.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'autotests/kconfigloadertest.cpp') diff --git a/autotests/kconfigloadertest.cpp b/autotests/kconfigloadertest.cpp index 27a90916..ab93c1da 100644 --- a/autotests/kconfigloadertest.cpp +++ b/autotests/kconfigloadertest.cpp @@ -12,10 +12,10 @@ Q_DECLARE_METATYPE(QList) -const QString TEST_NAME(QStringLiteral("kconfigloadertest")); +static const QString s_testName(QStringLiteral("kconfigloadertest")); // clazy:exclude=non-pod-global-static #define GET_CONFIG_ITEM_VALUE(type, configName) \ - KConfigSkeletonItem* item = cl->findItem(TEST_NAME, configName); \ + KConfigSkeletonItem* item = cl->findItem(s_testName, configName); \ /* Check if we got back a valid item. */ \ QVERIFY(item != nullptr); \ /* Cast the item to the given type. */ \ @@ -25,7 +25,7 @@ const QString TEST_NAME(QStringLiteral("kconfigloadertest")); void ConfigLoaderTest::init() { - QString fileName = TEST_NAME + QLatin1String(".xml"); + QString fileName = s_testName + QLatin1String(".xml"); configFile = new QFile(QFINDTESTDATA(QString::fromLatin1("/") + fileName)); cl = new KConfigLoader(configFile->fileName(), configFile); } -- cgit v1.2.1