diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2022-07-01 21:51:06 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2022-08-04 00:37:35 -0700 |
commit | e0eb93d9a2b104ac8d7596c419d1f13dc9db9b1b (patch) | |
tree | ba42c1f05f3ec31dd823aab6ef32e8b08bfde204 /src/corelib/text/qbytearrayview.h | |
parent | 751919d4de2dc8bc7e5898ec8dff64e3ef9eec0f (diff) |
QLatin1StringView: delegate operator== to QByteArrayView
It's the same implementation. This also inlines the actual comparison,
to allow the compiler to implement the inline memcmp, if it so wishes.
operator< could be changed too, but QByteArrayView's makes an out-of-
line call to QtPrivate::compareMemory, whereas QLatin1StringView's calls
memcmp() directly, which allows the compiler to optimize.
Change-Id: I89c4eb48af38408daa7cfffd16fde9f2b0a8590b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/text/qbytearrayview.h')
-rw-r--r-- | src/corelib/text/qbytearrayview.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/text/qbytearrayview.h b/src/corelib/text/qbytearrayview.h index e8ae1e2c80..e0e318249c 100644 --- a/src/corelib/text/qbytearrayview.h +++ b/src/corelib/text/qbytearrayview.h @@ -300,7 +300,7 @@ public: [[nodiscard]] constexpr char last() const { return back(); } friend inline bool operator==(QByteArrayView lhs, QByteArrayView rhs) noexcept - { return lhs.size() == rhs.size() && QtPrivate::compareMemory(lhs, rhs) == 0; } + { return lhs.size() == rhs.size() && (!lhs.size() || memcmp(lhs.data(), rhs.data(), lhs.size()) == 0); } friend inline bool operator!=(QByteArrayView lhs, QByteArrayView rhs) noexcept { return !(lhs == rhs); } friend inline bool operator< (QByteArrayView lhs, QByteArrayView rhs) noexcept |