diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-07-30 17:36:14 +0200 |
---|---|---|
committer | MÃ¥rten Nordheim <marten.nordheim@qt.io> | 2020-10-06 11:16:36 +0200 |
commit | fa8d021fa6fcb040fb702b6ffd2deee52a3b748a (patch) | |
tree | 15c6a311dcf9e6c64a162ba62d2d9a83846ba159 /src/corelib/io | |
parent | 40874625f996899ca1e976f0240da697e784c2c6 (diff) |
Convert a couple of APIs to use views
Try to get rid of APIs that use raw 'const {char, QChar} *, length'
pairs. Instead, use QByteArrayView or QStringView.
As QStringConverter is a new class, simply change the API to what we'd like
to have. Also adjust hidden API in QStringBuilder and friends.
Change-Id: I897d47f63a7b965f5574a1e51da64147f9e981f6
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qfilesystemiterator_unix.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qsettings.cpp | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/io/qfilesystemiterator_unix.cpp b/src/corelib/io/qfilesystemiterator_unix.cpp index c69138e3ba..cf01eeff15 100644 --- a/src/corelib/io/qfilesystemiterator_unix.cpp +++ b/src/corelib/io/qfilesystemiterator_unix.cpp @@ -56,7 +56,7 @@ static bool checkNameDecodable(const char *d_name, qsizetype len) // This function is called in a loop from advance() below, but the loop is // usually run only once. - return QUtf8::isValidUtf8(d_name, len).isValidUtf8; + return QUtf8::isValidUtf8(QByteArrayView(d_name, len)).isValidUtf8; } QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters, diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 42a0f38be3..547f2759f5 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -667,7 +667,7 @@ void QSettingsPrivate::iniEscapedString(const QString &str, QByteArray &result) escapeNextIfDigit = true; } else if (useCodec) { // slow - result += toUtf8(&unicode[i], 1); + result += toUtf8(unicode[i]); } else { result += (char)ch; } @@ -815,7 +815,7 @@ StNormal: ++j; } - stringResult += fromUtf8(str.constData() + i, j - i); + stringResult += fromUtf8(QByteArrayView(str).first(j).sliced(i)); i = j; } } |