From 78891e53905591eb6736a69296b31e12c3195a55 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 15 Mar 2022 15:34:39 +0100 Subject: [PATCH] QString/QByteArray: = default the move ctors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of relying on implicit construction of the d-pointer and then swapping that with other.d (using overly-generic qSwap(), no less), simply let the compiler do The Right Thing™ via QArrayDataPointer's move constructor. Pick-to: 6.3 6.2 Task-number: QTBUG-97601 Change-Id: I3be30f99f6fb0e17d3550edbe64cbe80880e604a Reviewed-by: Thiago Macieira Reviewed-by: Mårten Nordheim --- src/corelib/text/qbytearray.h | 2 +- src/corelib/text/qstring.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index bacc023cdfd..5a6dc354ba0 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -121,7 +121,7 @@ public: QByteArray &operator=(const QByteArray &) noexcept; QByteArray &operator=(const char *str); inline QByteArray(QByteArray && other) noexcept - { qSwap(d, other.d); } + = default; QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QByteArray) inline void swap(QByteArray &other) noexcept { d.swap(other.d); } diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index b30f4ac981b..a7f0f2451fc 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -462,7 +462,7 @@ public: QString &operator=(const QString &) noexcept; QString &operator=(QLatin1String latin1); inline QString(QString &&other) noexcept - { qSwap(d, other.d); } + = default; QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QString) void swap(QString &other) noexcept { d.swap(other.d); } inline qsizetype size() const { return d.size; }