From 0e742c9addd4d5202df20f03c3cc2ef984150f52 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 27 Nov 2020 18:18:07 +0100 Subject: [PATCH] Inline QCollator's QString methods via QStringView Can't be done before Qt 7 unless we do it now, as it'd be BiC. Task-number: QTBUG-86400 Change-Id: Ib7b2e7b20b4a80b53dfc6535efe90d1674f38e81 Reviewed-by: Lars Knoll (cherry picked from commit 53a1e015fdb4082900f306b5e2cca7bd5df77d03) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/text/qcollator.cpp | 10 ++-------- src/corelib/text/qcollator.h | 6 ++++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/corelib/text/qcollator.cpp b/src/corelib/text/qcollator.cpp index 646c0c57b6b..b6c9f7680ab 100644 --- a/src/corelib/text/qcollator.cpp +++ b/src/corelib/text/qcollator.cpp @@ -322,15 +322,13 @@ bool QCollator::ignorePunctuation() const */ /*! + \fn int QCollator::compare(const QString &s1, const QString &s2) const \overload \since 5.2 */ -int QCollator::compare(const QString &s1, const QString &s2) const -{ - return compare(QStringView(s1), QStringView(s2)); -} /*! + \fn int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) const \overload \since 5.2 @@ -340,10 +338,6 @@ int QCollator::compare(const QString &s1, const QString &s2) const Returns an integer less than, equal to, or greater than zero depending on whether \a s1 sorts before, with or after \a s2. */ -int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) const -{ - return compare(QStringView(s1, len1), QStringView(s2, len2)); -} #endif // QT_STRINGVIEW_LEVEL < 2 /*! diff --git a/src/corelib/text/qcollator.h b/src/corelib/text/qcollator.h index eebd675ec1a..2063dfb4a18 100644 --- a/src/corelib/text/qcollator.h +++ b/src/corelib/text/qcollator.h @@ -102,8 +102,10 @@ public: bool ignorePunctuation() const; #if QT_STRINGVIEW_LEVEL < 2 - int compare(const QString &s1, const QString &s2) const; - int compare(const QChar *s1, int len1, const QChar *s2, int len2) const; + int compare(const QString &s1, const QString &s2) const + { return compare(QStringView(s1), QStringView(s2)); } + int compare(const QChar *s1, int len1, const QChar *s2, int len2) const + { return compare(QStringView(s1, len1), QStringView(s2, len2)); } bool operator()(const QString &s1, const QString &s2) const { return compare(s1, s2) < 0; }