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 <thiago.macieira@intel.com>
This commit is contained in:
Fabian Kosmale 2021-03-20 19:39:48 +01:00
parent 58437836f0
commit 52e0a91fbc

View File

@ -322,7 +322,8 @@ private:
[[nodiscard]] friend inline bool operator==(QBasicUtf8StringView lhs, QBasicUtf8StringView rhs) noexcept [[nodiscard]] friend inline bool operator==(QBasicUtf8StringView lhs, QBasicUtf8StringView rhs) noexcept
{ {
return QtPrivate::equalStrings(QBasicUtf8StringView<false>(lhs.data(), lhs.size()), return lhs.size() == rhs.size() &&
QtPrivate::equalStrings(QBasicUtf8StringView<false>(lhs.data(), lhs.size()),
QBasicUtf8StringView<false>(rhs.data(), rhs.size())); QBasicUtf8StringView<false>(rhs.data(), rhs.size()));
} }
[[nodiscard]] friend inline bool operator!=(QBasicUtf8StringView lhs, QBasicUtf8StringView rhs) noexcept [[nodiscard]] friend inline bool operator!=(QBasicUtf8StringView lhs, QBasicUtf8StringView rhs) noexcept