From a769ab62cbcf957d049c8da74f898527dd27b328 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 7 Dec 2018 11:52:59 +0100 Subject: 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 --- src/corelib/tools/qcollator_macx.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'src/corelib/tools/qcollator_macx.cpp') diff --git a/src/corelib/tools/qcollator_macx.cpp b/src/corelib/tools/qcollator_macx.cpp index 42e67e0c12..9998ec4cda 100644 --- a/src/corelib/tools/qcollator_macx.cpp +++ b/src/corelib/tools/qcollator_macx.cpp @@ -97,18 +97,18 @@ void QCollatorPrivate::cleanup() collator = 0; } -int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) const +int QCollator::compare(QStringView s1, QStringView s2) const { if (d->dirty) d->init(); if (!d->collator) - return QStringView(s1, len1).compare(QStringView(s2, len2), caseSensitivity()); + return s1.compare(s2, caseSensitivity()); SInt32 result; Boolean equivalent; UCCompareText(d->collator, - reinterpret_cast(s1), len1, - reinterpret_cast(s2), len2, + reinterpret_cast(s1.data()), s1.size(), + reinterpret_cast(s2.data()), s2.size(), &equivalent, &result); if (equivalent) @@ -116,16 +116,6 @@ int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) con return result < 0 ? -1 : 1; } -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) -- cgit v1.2.3