diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2024-02-15 15:10:56 +0100 |
---|---|---|
committer | Ivan Solovev <ivan.solovev@qt.io> | 2024-02-20 01:04:34 +0100 |
commit | 77bec4f7c837cba16fc746ada9de370ae0b23922 (patch) | |
tree | d2d1a61bf7846ca16a12b11cb69e0a836a50a841 /src/corelib/text/qstring.h | |
parent | 4832426d1b22099cbdacaede17a4fd50336b9ae3 (diff) |
Simplify QLatin1StringView vs byte array relational operators
Now when QLatin1StringView implements relational operators with
QByteArrayView in terms of new comparison helper macros and helper
methods taking QByteArrayView, we can easily re-use these helper
methods to provide comparison with QByteArray and const char *.
QLatin1StringView already provided almost all of these operations,
partly as hidden friend functions, partly as inline methods.
Since the class is not exported, and the methods were inline, we
can just remove all of them and replace them with the comparison
helper macros.
This should speed up the relational operators, because they do not
construct string objects using QString::fromUtf8() anymore, but use
QUtf8StringView instead.
This also adds the previously missing QByteArray vs QLatin1StringView
relational operators.
Task-number: QTBUG-117661
Change-Id: I17a9185127ae130dab9409c6340a58f5d39f5a10
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/text/qstring.h')
-rw-r--r-- | src/corelib/text/qstring.h | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 84f95d28a7..780b3090c1 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -1336,35 +1336,6 @@ bool QString::operator<=(const char *s) const bool QString::operator>=(const char *s) const { return QString::compare_helper(constData(), size(), s, -1) >= 0; } -// -// QLatin1StringView inline members that require QString: -// -QT_ASCII_CAST_WARN bool QLatin1StringView::operator==(const char *s) const -{ return QString::fromUtf8(s) == *this; } -QT_ASCII_CAST_WARN bool QLatin1StringView::operator!=(const char *s) const -{ return QString::fromUtf8(s) != *this; } -QT_ASCII_CAST_WARN bool QLatin1StringView::operator<(const char *s) const -{ return QString::fromUtf8(s) > *this; } -QT_ASCII_CAST_WARN bool QLatin1StringView::operator>(const char *s) const -{ return QString::fromUtf8(s) < *this; } -QT_ASCII_CAST_WARN bool QLatin1StringView::operator<=(const char *s) const -{ return QString::fromUtf8(s) >= *this; } -QT_ASCII_CAST_WARN bool QLatin1StringView::operator>=(const char *s) const -{ return QString::fromUtf8(s) <= *this; } - -QT_ASCII_CAST_WARN bool QLatin1StringView::operator==(const QByteArray &s) const -{ return QString::fromUtf8(s) == *this; } -QT_ASCII_CAST_WARN bool QLatin1StringView::operator!=(const QByteArray &s) const -{ return QString::fromUtf8(s) != *this; } -QT_ASCII_CAST_WARN bool QLatin1StringView::operator<(const QByteArray &s) const -{ return QString::fromUtf8(s) > *this; } -QT_ASCII_CAST_WARN bool QLatin1StringView::operator>(const QByteArray &s) const -{ return QString::fromUtf8(s) < *this; } -QT_ASCII_CAST_WARN bool QLatin1StringView::operator<=(const QByteArray &s) const -{ return QString::fromUtf8(s) >= *this; } -QT_ASCII_CAST_WARN bool QLatin1StringView::operator>=(const QByteArray &s) const -{ return QString::fromUtf8(s) <= *this; } - QT_ASCII_CAST_WARN bool QString::operator==(const QByteArray &s) const { return QString::compare_helper(constData(), size(), s.constData(), s.size()) == 0; } QT_ASCII_CAST_WARN bool QString::operator!=(const QByteArray &s) const |