From 751919d4de2dc8bc7e5898ec8dff64e3ef9eec0f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 1 Jul 2022 21:45:58 -0700 Subject: [PATCH] QByteArray: delegate more of operator== & !+ to QByteArrayView QByteArrayView is capable of dealing with null pointers. Change-Id: I89c4eb48af38408daa7cfffd16fde9ab021ebf06 Reviewed-by: Marc Mutz --- src/corelib/text/qbytearray.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index 888c3b96d5..d73224cf17 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -274,15 +274,15 @@ public: friend inline bool operator==(const QByteArray &a1, const QByteArray &a2) noexcept { return QByteArrayView(a1) == QByteArrayView(a2); } friend inline bool operator==(const QByteArray &a1, const char *a2) noexcept - { return a2 ? QtPrivate::compareMemory(a1, a2) == 0 : a1.isEmpty(); } + { return QByteArrayView(a1) == QByteArrayView(a2); } friend inline bool operator==(const char *a1, const QByteArray &a2) noexcept - { return a1 ? QtPrivate::compareMemory(a1, a2) == 0 : a2.isEmpty(); } + { return QByteArrayView(a1) == QByteArrayView(a2); } friend inline bool operator!=(const QByteArray &a1, const QByteArray &a2) noexcept { return !(a1==a2); } friend inline bool operator!=(const QByteArray &a1, const char *a2) noexcept - { return a2 ? QtPrivate::compareMemory(a1, a2) != 0 : !a1.isEmpty(); } + { return QByteArrayView(a1) != QByteArrayView(a2); } friend inline bool operator!=(const char *a1, const QByteArray &a2) noexcept - { return a1 ? QtPrivate::compareMemory(a1, a2) != 0 : !a2.isEmpty(); } + { return QByteArrayView(a1) != QByteArrayView(a2); } friend inline bool operator<(const QByteArray &a1, const QByteArray &a2) noexcept { return QtPrivate::compareMemory(QByteArrayView(a1), QByteArrayView(a2)) < 0; } friend inline bool operator<(const QByteArray &a1, const char *a2) noexcept