diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2022-03-21 15:01:31 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2022-03-30 21:37:24 +0200 |
commit | 08d20ee85092851547fb4dfee67e98bf7b37c936 (patch) | |
tree | 8af9ba85c32a83e2c3743246ff11ec317e7ed3b2 /src/corelib/io/qsettings.cpp | |
parent | b4d003c77f947111b809c9f7c836a221f3981ba2 (diff) |
Use QByteArrayView more in QConfFileSettingsPrivate's methods
Avoid allocating QBA methods when the QBAV methods can do just as
well, especially where the QBA was already being QBAV-wrapped to avoid
such allocations.
Change-Id: I180c2316362685ffda613bab2c761e72c4483fce
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/io/qsettings.cpp')
-rw-r--r-- | src/corelib/io/qsettings.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 52f54d12f4..683693b8f4 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -573,9 +573,9 @@ void QSettingsPrivate::iniEscapedKey(const QString &key, QByteArray &result) } } -bool QSettingsPrivate::iniUnescapedKey(const QByteArray &key, int from, int to, QString &result) +bool QSettingsPrivate::iniUnescapedKey(QByteArrayView key, int from, int to, QString &result) { - const QString decoded = QString::fromUtf8(QByteArrayView(key).first(to).sliced(from)); + const QString decoded = QString::fromUtf8(key.first(to).sliced(from)); const qsizetype size = decoded.size(); result.reserve(result.length() + size); qsizetype i = 0; @@ -740,7 +740,7 @@ void QSettingsPrivate::iniEscapedStringList(const QStringList &strs, QByteArray } } -bool QSettingsPrivate::iniUnescapedStringList(const QByteArray &str, int from, int to, +bool QSettingsPrivate::iniUnescapedStringList(QByteArrayView str, int from, int to, QString &stringResult, QStringList &stringListResult) { static const char escapeCodes[][2] = @@ -844,7 +844,7 @@ StNormal: ++j; } - stringResult += fromUtf8(QByteArrayView(str).first(j).sliced(i)); + stringResult += fromUtf8(str.first(j).sliced(i)); i = j; } } @@ -1535,7 +1535,7 @@ static const char charTraits[256] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -bool QConfFileSettingsPrivate::readIniLine(const QByteArray &data, int &dataPos, +bool QConfFileSettingsPrivate::readIniLine(QByteArrayView data, int &dataPos, int &lineStart, int &lineLen, int &equalsPos) { int dataLen = data.length(); @@ -1606,7 +1606,7 @@ break_out_of_outer_loop: possible, so if the user doesn't check the status he will get the most out of the file anyway. */ -bool QConfFileSettingsPrivate::readIniFile(const QByteArray &data, +bool QConfFileSettingsPrivate::readIniFile(QByteArrayView data, UnparsedSettingsMap *unparsedIniSections) { #define FLUSH_CURRENT_SECTION() \ @@ -1641,13 +1641,13 @@ bool QConfFileSettingsPrivate::readIniFile(const QByteArray &data, FLUSH_CURRENT_SECTION(); // this is a section - QByteArray iniSection; + QByteArrayView iniSection; int idx = data.indexOf(']', lineStart); if (idx == -1 || idx >= lineStart + lineLen) { ok = false; - iniSection = data.mid(lineStart + 1, lineLen - 1); + iniSection = data.sliced(lineStart + 1, lineLen - 1); } else { - iniSection = data.mid(lineStart + 1, idx - lineStart - 1); + iniSection = data.sliced(lineStart + 1, idx - lineStart - 1); } iniSection = iniSection.trimmed(); @@ -1676,7 +1676,7 @@ bool QConfFileSettingsPrivate::readIniFile(const QByteArray &data, #undef FLUSH_CURRENT_SECTION } -bool QConfFileSettingsPrivate::readIniSection(const QSettingsKey §ion, const QByteArray &data, +bool QConfFileSettingsPrivate::readIniSection(const QSettingsKey §ion, QByteArrayView data, ParsedSettingsMap *settingsMap) { QStringList strListValue; |