diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2018-12-07 11:52:59 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2019-03-08 17:07:38 +0000 |
commit | a769ab62cbcf957d049c8da74f898527dd27b328 (patch) | |
tree | a1f3607ae1472ad39fb1e8662f3781c4e669deeb /src/corelib/tools/qcollator_posix.cpp | |
parent | e89fbd8c3aa50a24e5fc02ab710ccca67fce98e2 (diff) |
Extend QCollator to support QStringView
This enables some simplification of the existing implementations.
Refined wording of the documentation in the process.
[ChangeLog][QtCore][QCollator] Added support for QStringView.
Change-Id: Idffaae8d109173d47c7be076828f4b58dc334957
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qcollator_posix.cpp')
-rw-r--r-- | src/corelib/tools/qcollator_posix.cpp | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/src/corelib/tools/qcollator_posix.cpp b/src/corelib/tools/qcollator_posix.cpp index 81f97a02e1..9cbc539ebe 100644 --- a/src/corelib/tools/qcollator_posix.cpp +++ b/src/corelib/tools/qcollator_posix.cpp @@ -65,7 +65,7 @@ void QCollatorPrivate::cleanup() { } -static void stringToWCharArray(QVarLengthArray<wchar_t> &ret, const QString &string) +static void stringToWCharArray(QVarLengthArray<wchar_t> &ret, QStringView string) { ret.resize(string.length()); int len = string.toWCharArray(ret.data()); @@ -73,12 +73,7 @@ static void stringToWCharArray(QVarLengthArray<wchar_t> &ret, const QString &str ret[len] = 0; } -int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) const -{ - return compare(QString::fromRawData(s1, len1), QString::fromRawData(s2, len2)); -} - -int QCollator::compare(const QString &s1, const QString &s2) const +int QCollator::compare(QStringView s1, QStringView s2) const { if (d->isC()) return s1.compare(s2, caseSensitivity()); @@ -91,11 +86,6 @@ int QCollator::compare(const QString &s1, const QString &s2) const return std::wcscoll(array1.constData(), array2.constData()); } -int QCollator::compare(const QStringRef &s1, const QStringRef &s2) const -{ - return compare(s1.toString(), s2.toString()); -} - QCollatorSortKey QCollator::sortKey(const QString &string) const { if (d->dirty) |