diff options
author | Friedrich W. H. Kossebau <kossebau@kde.org> | 2021-11-14 19:26:34 +0100 |
---|---|---|
committer | Friedrich W. H. Kossebau <kossebau@kde.org> | 2021-11-14 19:26:34 +0100 |
commit | c3be6d02f6c061707c6d93e06889a2e56b994d87 (patch) | |
tree | 413f81904db72616b064923c6a6d1fa021675af4 /src/kconf_update/kconf_update.cpp | |
parent | 473a9137db305ea69cb4b40f23ed679c90c4b475 (diff) | |
download | kconfig-c3be6d02f6c061707c6d93e06889a2e56b994d87.tar.gz kconfig-c3be6d02f6c061707c6d93e06889a2e56b994d87.tar.bz2 |
Avoid some allocations by QString/QByteArray's toLower()
NO_CHANGELOG
Diffstat (limited to 'src/kconf_update/kconf_update.cpp')
-rw-r--r-- | src/kconf_update/kconf_update.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp index 8cbbc3c3..0e9744a0 100644 --- a/src/kconf_update/kconf_update.cpp +++ b/src/kconf_update/kconf_update.cpp @@ -35,6 +35,11 @@ // the file. #define qCDebugFile(CATEGORY) qCDebug(CATEGORY) << m_currentFilename << ':' << m_lineCount << ":'" << m_line << "': " +static bool caseInsensitiveCompare(const QStringView &a, const QLatin1String &b) +{ + return a.compare(b, Qt::CaseInsensitive) == 0; +} + class KonfUpdate { public: @@ -701,11 +706,11 @@ void KonfUpdate::gotOptions(const QString &_options) { const QStringList options = _options.split(QLatin1Char{','}); for (const auto &opt : options) { - const auto normalizedOpt = opt.toLower().trimmed(); + const auto normalizedOpt = QStringView(opt).trimmed(); - if (normalizedOpt == QLatin1String("copy")) { + if (caseInsensitiveCompare(normalizedOpt, QLatin1String("copy"))) { m_bCopy = true; - } else if (normalizedOpt == QLatin1String("overwrite")) { + } else if (caseInsensitiveCompare(normalizedOpt, QLatin1String("overwrite"))) { m_bOverwrite = true; } } |