diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-05-11 17:00:22 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-05-11 17:48:20 +0000 |
commit | a8d45d7d0e9d9e216231f8825f1034c39e999e28 (patch) | |
tree | 0c4492b5a7ce18d281da61549b172cc3592f4f4f | |
parent | 2e53218a430597bfbcf226973ccd0b4c46192af3 (diff) |
QtMQTT: replace qSwap with std::swap/member-swap where possible
qSwap() is a monster that looks for ADL overloads of swap() and also
detects the noexcept of the wrapped swap() function, so it should only
be used when the argument type is unknown. In the vast majority of
cases, the type is known to be efficiently std::swap()able or to have
a member-swap. Call either of these.
As a drive-by, remove pointless inline adornments, port Q_DECL_NOTHROW
to noexcept, and fix the move-assignment operators to call member-swap
instead of swapping manually.
Task-number: QTBUG-97601
Change-Id: I2526194a426333e9f2773e5965458289459d1b4d
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 0cb10269bfbea3cfb02d340e47c7723562e240dc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/mqtt/qmqtttopicfilter.h | 4 | ||||
-rw-r--r-- | src/mqtt/qmqtttopicname.h | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/mqtt/qmqtttopicfilter.h b/src/mqtt/qmqtttopicfilter.h index 39e3510..fafdf51 100644 --- a/src/mqtt/qmqtttopicfilter.h +++ b/src/mqtt/qmqtttopicfilter.h @@ -61,10 +61,10 @@ public: QMqttTopicFilter &operator=(const QMqttTopicFilter &filter); #ifdef Q_COMPILER_RVALUE_REFS - inline QMqttTopicFilter &operator=(QMqttTopicFilter &&other) Q_DECL_NOTHROW { qSwap(d, other.d); return *this; } + QMqttTopicFilter &operator=(QMqttTopicFilter &&other) noexcept { swap(other); return *this; } #endif - inline void swap(QMqttTopicFilter &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QMqttTopicFilter &other) noexcept { d.swap(other.d); } QString filter() const; void setFilter(const QString &filter); diff --git a/src/mqtt/qmqtttopicname.h b/src/mqtt/qmqtttopicname.h index c2ae6e5..17590b3 100644 --- a/src/mqtt/qmqtttopicname.h +++ b/src/mqtt/qmqtttopicname.h @@ -55,10 +55,10 @@ public: QMqttTopicName &operator=(const QMqttTopicName &name); #ifdef Q_COMPILER_RVALUE_REFS - inline QMqttTopicName &operator=(QMqttTopicName &&other) Q_DECL_NOTHROW { qSwap(d, other.d); return *this; } + QMqttTopicName &operator=(QMqttTopicName &&other) noexcept { swap(other); return *this; } #endif - inline void swap(QMqttTopicName &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QMqttTopicName &other) noexcept { d.swap(other.d); } QString name() const; void setName(const QString &name); |