summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qcollator_win.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2018-12-07 11:52:59 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2019-03-08 17:07:38 +0000
commita769ab62cbcf957d049c8da74f898527dd27b328 (patch)
treea1f3607ae1472ad39fb1e8662f3781c4e669deeb /src/corelib/tools/qcollator_win.cpp
parente89fbd8c3aa50a24e5fc02ab710ccca67fce98e2 (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_win.cpp')
-rw-r--r--src/corelib/tools/qcollator_win.cpp23
1 files changed, 6 insertions, 17 deletions
diff --git a/src/corelib/tools/qcollator_win.cpp b/src/corelib/tools/qcollator_win.cpp
index 35142bb8b8..9cbdd96ee0 100644
--- a/src/corelib/tools/qcollator_win.cpp
+++ b/src/corelib/tools/qcollator_win.cpp
@@ -85,11 +85,10 @@ void QCollatorPrivate::cleanup()
{
}
-
-int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) const
+int QCollator::compare(QStringView s1, QStringView s2) const
{
if (d->isC())
- return QString::compare_helper(s1, len1, s2, len2, d->caseSensitivity);
+ return s1.compare(s2, d->caseSensitivity);
if (d->dirty)
d->init();
@@ -101,25 +100,15 @@ int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) con
#ifndef USE_COMPARESTRINGEX
return CompareString(d->localeID, d->collator,
- reinterpret_cast<const wchar_t*>(s1), len1,
- reinterpret_cast<const wchar_t*>(s2), len2) - 2;
+ reinterpret_cast<const wchar_t*>(s1.data()), s1.size(),
+ reinterpret_cast<const wchar_t*>(s2.data()), s2.size()) - 2;
#else
return CompareStringEx(LPCWSTR(d->localeName.utf16()), d->collator,
- reinterpret_cast<LPCWSTR>(s1), len1,
- reinterpret_cast<LPCWSTR>(s2), len2, NULL, NULL, 0) - 2;
+ reinterpret_cast<LPCWSTR>(s1.data()), s1.size(),
+ reinterpret_cast<LPCWSTR>(s2.data()), s2.size(), NULL, NULL, 0) - 2;
#endif
}
-int QCollator::compare(const QString &str1, const QString &str2) const
-{
- return compare(str1.constData(), str1.size(), str2.constData(), str2.size());
-}
-
-int QCollator::compare(const QStringRef &s1, const QStringRef &s2) const
-{
- return compare(s1.constData(), s1.size(), s2.constData(), s2.size());
-}
-
QCollatorSortKey QCollator::sortKey(const QString &string) const
{
if (d->dirty)