aboutsummaryrefslogtreecommitdiff
path: root/src/core/kconfig.cpp
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2021-05-02 17:50:05 +0200
committerDavid Faure <faure@kde.org>2021-05-02 18:09:09 +0000
commit1780fb2a237af80ddc1f9cfb70cb892b53b91990 (patch)
tree889e7adf0ec8d513d75e30a5e7ad939e149ba345 /src/core/kconfig.cpp
parent1164ef55e93b4171306899ab786bfd0acaa00847 (diff)
downloadkconfig-1780fb2a237af80ddc1f9cfb70cb892b53b91990.tar.gz
kconfig-1780fb2a237af80ddc1f9cfb70cb892b53b91990.tar.bz2
Minor code refactoring
Some methods in ConfigLoaderHandler always returned true, change them to return void instead. Also port them to take a QStringView instead of QStringRef, this doesn't require a lot of changes because a QStringView can be constructed from a QStringRef. QXmlStreamAttribute methods like value() and name() return QStringRef in Qt5 and QStringView in Qt6, "fix" the issue by using auto keyword, which works in both cases. QStringView::toInt() isn't efficient in Qt5 so make the build conditional. NO_CHANGELOG
Diffstat (limited to 'src/core/kconfig.cpp')
-rw-r--r--src/core/kconfig.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp
index cc3700e1..8118ea51 100644
--- a/src/core/kconfig.cpp
+++ b/src/core/kconfig.cpp
@@ -174,21 +174,21 @@ QString KConfigPrivate::expandString(const QString &value)
int nDollarPos = aValue.indexOf(QLatin1Char('$'));
while (nDollarPos != -1 && nDollarPos + 1 < aValue.length()) {
// there is at least one $
- if (aValue[nDollarPos + 1] != QLatin1Char('$')) {
+ if (aValue.at(nDollarPos + 1) != QLatin1Char('$')) {
int nEndPos = nDollarPos + 1;
// the next character is not $
- QStringRef aVarName;
- if (aValue[nEndPos] == QLatin1Char('{')) {
+ QStringView aVarName;
+ if (aValue.at(nEndPos) == QLatin1Char('{')) {
while ((nEndPos <= aValue.length()) && (aValue[nEndPos] != QLatin1Char('}'))) {
++nEndPos;
}
++nEndPos;
- aVarName = aValue.midRef(nDollarPos + 2, nEndPos - nDollarPos - 3);
+ aVarName = QStringView(aValue).mid(nDollarPos + 2, nEndPos - nDollarPos - 3);
} else {
while (nEndPos < aValue.length() && (aValue[nEndPos].isNumber() || aValue[nEndPos].isLetter() || aValue[nEndPos] == QLatin1Char('_'))) {
++nEndPos;
}
- aVarName = aValue.midRef(nDollarPos + 1, nEndPos - nDollarPos - 1);
+ aVarName = QStringView(aValue).mid(nDollarPos + 1, nEndPos - nDollarPos - 1);
}
QString env;
if (!aVarName.isEmpty()) {