From 52e0a91fbc187ca09d3ea6279e8bdce982edc586 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Sat, 20 Mar 2021 19:39:48 +0100 Subject: [PATCH] QUtf8StringView: Check size directly in operator== We can avoid the non-inlined function call if the sizes do not match up. This aligns the implementation of QUtf8StringView's operator== with the one used for the other string classes. Change-Id: Iaaf71b236edc0385551639961f753f11b324b327 Reviewed-by: Thiago Macieira --- src/corelib/text/qutf8stringview.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/text/qutf8stringview.h b/src/corelib/text/qutf8stringview.h index 8e0656660d..5069bf7b07 100644 --- a/src/corelib/text/qutf8stringview.h +++ b/src/corelib/text/qutf8stringview.h @@ -322,7 +322,8 @@ private: [[nodiscard]] friend inline bool operator==(QBasicUtf8StringView lhs, QBasicUtf8StringView rhs) noexcept { - return QtPrivate::equalStrings(QBasicUtf8StringView(lhs.data(), lhs.size()), + return lhs.size() == rhs.size() && + QtPrivate::equalStrings(QBasicUtf8StringView(lhs.data(), lhs.size()), QBasicUtf8StringView(rhs.data(), rhs.size())); } [[nodiscard]] friend inline bool operator!=(QBasicUtf8StringView lhs, QBasicUtf8StringView rhs) noexcept