diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-05-06 17:33:46 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-05-09 18:19:33 +0000 |
commit | f073954fdc07c4e4599314dd4a47cef27bf3f538 (patch) | |
tree | cc348b1b426fa7964afdc792454a072be53e6433 /src | |
parent | 48070b83d5df98e78bc42a05319cf0cbe6bb5ada (diff) |
QtConnectivity: 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.
For the common case of pointer types, circumvent the expensive trait
checks on std::swap() by using our hand-rolled qt_ptr_swap() template,
the advantage being that it can be unconditionally noexcept, removing
all type traits instantiations.
As a drive-by, port Q_DECL_NOTHROW to noexcept, which has been
available to us since Qt 5.7.
Task-number: QTBUG-97601
Change-Id: I08ef8e0c252854e4a9905da77448f280681cc7a3
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 4ae9fb1ebff91bee1f59a0cbb40fcb51005123a6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/bluetooth/qlowenergyadvertisingdata.h | 2 | ||||
-rw-r--r-- | src/bluetooth/qlowenergyadvertisingparameters.h | 2 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycharacteristicdata.h | 2 | ||||
-rw-r--r-- | src/bluetooth/qlowenergyconnectionparameters.h | 2 | ||||
-rw-r--r-- | src/bluetooth/qlowenergydescriptordata.h | 2 | ||||
-rw-r--r-- | src/bluetooth/qlowenergyservicedata.h | 2 |
6 files changed, 6 insertions, 6 deletions
diff --git a/src/bluetooth/qlowenergyadvertisingdata.h b/src/bluetooth/qlowenergyadvertisingdata.h index c5a2f22b..7ed61caa 100644 --- a/src/bluetooth/qlowenergyadvertisingdata.h +++ b/src/bluetooth/qlowenergyadvertisingdata.h @@ -84,7 +84,7 @@ public: void setRawData(const QByteArray &data); QByteArray rawData() const; - void swap(QLowEnergyAdvertisingData &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QLowEnergyAdvertisingData &other) noexcept { d.swap(other.d); } private: QSharedDataPointer<QLowEnergyAdvertisingDataPrivate> d; diff --git a/src/bluetooth/qlowenergyadvertisingparameters.h b/src/bluetooth/qlowenergyadvertisingparameters.h index b8a4d763..398c9898 100644 --- a/src/bluetooth/qlowenergyadvertisingparameters.h +++ b/src/bluetooth/qlowenergyadvertisingparameters.h @@ -90,7 +90,7 @@ public: // TODO: own address type // TODO: For ADV_DIRECT_IND: peer address + peer address type - void swap(QLowEnergyAdvertisingParameters &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QLowEnergyAdvertisingParameters &other) noexcept { d.swap(other.d); } private: QSharedDataPointer<QLowEnergyAdvertisingParametersPrivate> d; diff --git a/src/bluetooth/qlowenergycharacteristicdata.h b/src/bluetooth/qlowenergycharacteristicdata.h index 5fb2f597..64c53528 100644 --- a/src/bluetooth/qlowenergycharacteristicdata.h +++ b/src/bluetooth/qlowenergycharacteristicdata.h @@ -82,7 +82,7 @@ public: bool isValid() const; - void swap(QLowEnergyCharacteristicData &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QLowEnergyCharacteristicData &other) noexcept { d.swap(other.d); } private: QSharedDataPointer<QLowEnergyCharacteristicDataPrivate> d; diff --git a/src/bluetooth/qlowenergyconnectionparameters.h b/src/bluetooth/qlowenergyconnectionparameters.h index 7076a95c..c7e1cac6 100644 --- a/src/bluetooth/qlowenergyconnectionparameters.h +++ b/src/bluetooth/qlowenergyconnectionparameters.h @@ -69,7 +69,7 @@ public: void setSupervisionTimeout(int timeout); int supervisionTimeout() const; - void swap(QLowEnergyConnectionParameters &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QLowEnergyConnectionParameters &other) noexcept { d.swap(other.d); } private: QSharedDataPointer<QLowEnergyConnectionParametersPrivate> d; diff --git a/src/bluetooth/qlowenergydescriptordata.h b/src/bluetooth/qlowenergydescriptordata.h index 5558f1e4..32c60350 100644 --- a/src/bluetooth/qlowenergydescriptordata.h +++ b/src/bluetooth/qlowenergydescriptordata.h @@ -80,7 +80,7 @@ public: bool isWritable() const; QBluetooth::AttAccessConstraints writeConstraints() const; - void swap(QLowEnergyDescriptorData &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QLowEnergyDescriptorData &other) noexcept { d.swap(other.d); } private: QSharedDataPointer<QLowEnergyDescriptorDataPrivate> d; diff --git a/src/bluetooth/qlowenergyservicedata.h b/src/bluetooth/qlowenergyservicedata.h index c0900918..1be4ee80 100644 --- a/src/bluetooth/qlowenergyservicedata.h +++ b/src/bluetooth/qlowenergyservicedata.h @@ -78,7 +78,7 @@ public: bool isValid() const; - void swap(QLowEnergyServiceData &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QLowEnergyServiceData &other) noexcept { d.swap(other.d); } private: QSharedDataPointer<QLowEnergyServiceDataPrivate> d; |