From 22a4fc0e38ba4da6fb14af965232ccf498f75668 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 1 Jul 2022 16:11:25 -0700 Subject: [PATCH] QByteArray: inline QByteArray::isNull() Keeping it out-of-line is unnecessary and has been since 5.0. In Qt 4.x, it was necessary to compare to the shared_null, which for QByteArray was a static variable. The one for QString has always been inline because the shared null was a static member of QString (in Qt 3, QString::null was a QString variable). See: https://code.qt.io/cgit/qt/qt.git/tree/src/corelib/tools/qbytearray.cpp#n3249 https://code.qt.io/cgit/qt/qt.git/tree/src/corelib/tools/qstring.h#n505 Change-Id: I89c4eb48af38408daa7cfffd16fdd7696520f1b6 Reviewed-by: Marc Mutz Reviewed-by: Fabian Kosmale (cherry picked from commit 999654fec7660cd5a724df26a4bc9f54e117a1b1) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/compat/removed_api.cpp | 2 ++ src/corelib/text/qbytearray.cpp | 5 ----- src/corelib/text/qbytearray.h | 8 ++++++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp index c2cff280011..dec623d3ff8 100644 --- a/src/corelib/compat/removed_api.cpp +++ b/src/corelib/compat/removed_api.cpp @@ -161,6 +161,8 @@ QByteArray QUrl::toAce(const QString &domain) #if QT_CORE_REMOVED_SINCE(6, 4) +#include "qbytearray.h" // uses QT_CORE_INLINE_SINCE + #include "qcalendar.h" QCalendar::QCalendar(QStringView name) diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 0c5bf462281..f728877e4a5 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -3480,11 +3480,6 @@ QByteArray QByteArray::rightJustified(qsizetype width, char fill, bool truncate) return result; } -bool QByteArray::isNull() const noexcept -{ - return d->isNull(); -} - auto QtPrivate::toSignedInteger(QByteArrayView data, int base) -> ParsedNumber { #if defined(QT_CHECK_RANGE) diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index a43a1a41280..888c3b96d56 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -439,6 +439,7 @@ public: inline qsizetype count() const noexcept { return size(); } #endif inline qsizetype length() const noexcept { return size(); } + QT_CORE_INLINE_SINCE(6, 4) bool isNull() const noexcept; inline DataPointer &data_ptr() { return d; } @@ -567,6 +568,13 @@ inline QByteArray &QByteArray::setNum(ulong n, int base) inline QByteArray &QByteArray::setNum(float n, char format, int precision) { return setNum(double(n), format, precision); } +#if QT_CORE_INLINE_IMPL_SINCE(6, 4) +bool QByteArray::isNull() const noexcept +{ + return d->isNull(); +} +#endif + #if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED) Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QByteArray &); Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QByteArray &);