From e0eb93d9a2b104ac8d7596c419d1f13dc9db9b1b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 1 Jul 2022 21:51:06 -0700 Subject: 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 --- src/corelib/text/qstring.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/text/qstring.cpp') diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 5369e1c6cb..e8dd1a6ccd 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -1402,7 +1402,7 @@ bool QtPrivate::equalStrings(QLatin1StringView lhs, QStringView rhs) noexcept bool QtPrivate::equalStrings(QLatin1StringView lhs, QLatin1StringView rhs) noexcept { - return lhs.size() == rhs.size() && (!lhs.size() || memcmp(lhs.data(), rhs.data(), lhs.size()) == 0); + return QByteArrayView(lhs) == QByteArrayView(rhs); } bool QtPrivate::equalStrings(QBasicUtf8StringView lhs, QStringView rhs) noexcept -- cgit v1.2.3