Simplify QConfFileSettingsPrivate::readIniSection() using QBAV
It needs fewer moving parts this way. In the process, to match the QString strValue, rename a QString key to strKey, freeing the name key for a view. Change-Id: Ic58145fd665db265d136545ced59e293a2eed1eb Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
64af542374
commit
e1d50add35
@ -1686,29 +1686,28 @@ bool QConfFileSettingsPrivate::readIniSection(const QSettingsKey §ion, QByte
|
|||||||
qsizetype position = section.originalKeyPosition();
|
qsizetype position = section.originalKeyPosition();
|
||||||
|
|
||||||
while (readIniLine(data, dataPos, lineStart, lineLen, equalsPos)) {
|
while (readIniLine(data, dataPos, lineStart, lineLen, equalsPos)) {
|
||||||
char ch = data.at(lineStart);
|
QByteArrayView line = data.sliced(lineStart, lineLen);
|
||||||
Q_ASSERT(ch != '[');
|
Q_ASSERT(!line.startsWith('['));
|
||||||
|
|
||||||
if (equalsPos == -1) {
|
if (equalsPos == -1) {
|
||||||
if (ch != ';')
|
if (!line.startsWith(';'))
|
||||||
ok = false;
|
ok = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// Shift equalPos indexing to be within line, rather than data:
|
||||||
|
equalsPos -= lineStart;
|
||||||
|
// Assured by readIniLine:
|
||||||
|
Q_ASSERT(equalsPos >= 0 && equalsPos < lineLen);
|
||||||
|
|
||||||
qsizetype keyEnd = equalsPos;
|
QByteArrayView key = line.first(equalsPos).trimmed();
|
||||||
while (keyEnd > lineStart && ((ch = data.at(keyEnd - 1)) == ' ' || ch == '\t'))
|
QByteArrayView value = line.sliced(equalsPos + 1);
|
||||||
--keyEnd;
|
|
||||||
qsizetype valueStart = equalsPos + 1;
|
|
||||||
|
|
||||||
QString key = section.originalCaseKey();
|
QString strKey = section.originalCaseKey();
|
||||||
bool keyIsLowercase
|
bool keyIsLowercase = iniUnescapedKey(key, strKey) && sectionIsLowercase;
|
||||||
= iniUnescapedKey(data.first(keyEnd).sliced(lineStart), key) && sectionIsLowercase;
|
|
||||||
|
|
||||||
QString strValue;
|
QString strValue;
|
||||||
strValue.reserve(lineLen - (valueStart - lineStart));
|
strValue.reserve(value.size());
|
||||||
bool isStringList
|
bool isStringList = iniUnescapedStringList(value, strValue, strListValue);
|
||||||
= iniUnescapedStringList(data.first(lineStart + lineLen).sliced(valueStart),
|
|
||||||
strValue, strListValue);
|
|
||||||
QVariant variant;
|
QVariant variant;
|
||||||
if (isStringList) {
|
if (isStringList) {
|
||||||
variant = stringListToVariantList(strListValue);
|
variant = stringListToVariantList(strListValue);
|
||||||
@ -1721,7 +1720,7 @@ bool QConfFileSettingsPrivate::readIniSection(const QSettingsKey §ion, QByte
|
|||||||
QSettingsKey by passing Qt::CaseSensitive when the
|
QSettingsKey by passing Qt::CaseSensitive when the
|
||||||
key is already in lowercase.
|
key is already in lowercase.
|
||||||
*/
|
*/
|
||||||
settingsMap->insert(QSettingsKey(key, keyIsLowercase ? Qt::CaseSensitive
|
settingsMap->insert(QSettingsKey(strKey, keyIsLowercase ? Qt::CaseSensitive
|
||||||
: IniCaseSensitivity,
|
: IniCaseSensitivity,
|
||||||
position),
|
position),
|
||||||
variant);
|
variant);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user