diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-03-15 21:20:46 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-03-17 07:15:01 +0100 |
commit | 870bb22c17e5578ead427821998b9e62201f7b5d (patch) | |
tree | 87e1545b5faee9013338c1ba37894b19d0001616 /src/dbus | |
parent | 9f8da21239a4d9e22a2d5633920c36af4eb4a6c7 (diff) |
QtDBus: compile-optimize inline swap functions
Instead of using the overly-generic qSwap() monster, use
- qt_ptr_swap() for swapping raw pointers
- member-swap for swapping smart pointers and owning containers
- std::swap() for swapping scalars
In QtCore, this has proven to give a nice reduction in compile time
for Qt users, cf. b1b0c2970e480ef460a61f37fa430dc443390358.
Pick-to: 6.3 6.2
Task-number: QTBUG-97601
Change-Id: I2cb0dd3cef3a2923e7d08bb9d93c692308797e5b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/dbus')
-rw-r--r-- | src/dbus/qdbusargument.h | 2 | ||||
-rw-r--r-- | src/dbus/qdbusconnection.h | 2 | ||||
-rw-r--r-- | src/dbus/qdbuserror.h | 6 | ||||
-rw-r--r-- | src/dbus/qdbusextratypes.h | 6 | ||||
-rw-r--r-- | src/dbus/qdbusmessage.h | 2 | ||||
-rw-r--r-- | src/dbus/qdbuspendingcall.h | 2 | ||||
-rw-r--r-- | src/dbus/qdbusunixfiledescriptor.h | 2 |
7 files changed, 11 insertions, 11 deletions
diff --git a/src/dbus/qdbusargument.h b/src/dbus/qdbusargument.h index cf09543912..bf4a6e40e6 100644 --- a/src/dbus/qdbusargument.h +++ b/src/dbus/qdbusargument.h @@ -81,7 +81,7 @@ public: QDBusArgument &operator=(const QDBusArgument &other); ~QDBusArgument(); - void swap(QDBusArgument &other) noexcept { qSwap(d, other.d); } + void swap(QDBusArgument &other) noexcept { qt_ptr_swap(d, other.d); } // used for marshalling (Qt -> D-BUS) QDBusArgument &operator<<(uchar arg); diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h index 43bc547894..1628c2bd7a 100644 --- a/src/dbus/qdbusconnection.h +++ b/src/dbus/qdbusconnection.h @@ -138,7 +138,7 @@ public: QDBusConnection &operator=(const QDBusConnection &other); ~QDBusConnection(); - void swap(QDBusConnection &other) noexcept { qSwap(d, other.d); } + void swap(QDBusConnection &other) noexcept { qt_ptr_swap(d, other.d); } bool isConnected() const; QString baseService() const; diff --git a/src/dbus/qdbuserror.h b/src/dbus/qdbuserror.h index 65baaa9562..8b3026a1fc 100644 --- a/src/dbus/qdbuserror.h +++ b/src/dbus/qdbuserror.h @@ -112,9 +112,9 @@ public: void swap(QDBusError &other) noexcept { - qSwap(code, other.code); - qSwap(msg, other.msg); - qSwap(nm, other.nm); + std::swap(code, other.code); + msg.swap(other.msg); + nm.swap(other.nm); } ErrorType type() const; diff --git a/src/dbus/qdbusextratypes.h b/src/dbus/qdbusextratypes.h index 59ab248dfa..0540a79447 100644 --- a/src/dbus/qdbusextratypes.h +++ b/src/dbus/qdbusextratypes.h @@ -64,7 +64,7 @@ public: inline explicit QDBusObjectPath(const QString &path); explicit QDBusObjectPath(QString &&p) : m_path(std::move(p)) { doCheck(); } - void swap(QDBusObjectPath &other) noexcept { qSwap(m_path, other.m_path); } + void swap(QDBusObjectPath &other) noexcept { m_path.swap(other.m_path); } inline void setPath(const QString &path); @@ -119,7 +119,7 @@ public: inline explicit QDBusSignature(const QString &signature); explicit QDBusSignature(QString &&sig) : m_signature(std::move(sig)) { doCheck(); } - void swap(QDBusSignature &other) noexcept { qSwap(m_signature, other.m_signature); } + void swap(QDBusSignature &other) noexcept { m_signature.swap(other.m_signature); } inline void setSignature(const QString &signature); @@ -169,7 +169,7 @@ public: inline explicit QDBusVariant(const QVariant &variant); explicit QDBusVariant(QVariant &&v) noexcept : m_variant(std::move(v)) {} - void swap(QDBusVariant &other) noexcept { qSwap(m_variant, other.m_variant); } + void swap(QDBusVariant &other) noexcept { m_variant.swap(other.m_variant); } inline void setVariant(const QVariant &variant); diff --git a/src/dbus/qdbusmessage.h b/src/dbus/qdbusmessage.h index e820b2427b..af467c8a88 100644 --- a/src/dbus/qdbusmessage.h +++ b/src/dbus/qdbusmessage.h @@ -71,7 +71,7 @@ public: QDBusMessage &operator=(const QDBusMessage &other); ~QDBusMessage(); - void swap(QDBusMessage &other) noexcept { qSwap(d_ptr, other.d_ptr); } + void swap(QDBusMessage &other) noexcept { qt_ptr_swap(d_ptr, other.d_ptr); } static QDBusMessage createSignal(const QString &path, const QString &interface, const QString &name); diff --git a/src/dbus/qdbuspendingcall.h b/src/dbus/qdbuspendingcall.h index dd99346301..727b038c77 100644 --- a/src/dbus/qdbuspendingcall.h +++ b/src/dbus/qdbuspendingcall.h @@ -63,7 +63,7 @@ public: QDBusPendingCall &operator=(QDBusPendingCall &&other) noexcept { swap(other); return *this; } QDBusPendingCall &operator=(const QDBusPendingCall &other); - void swap(QDBusPendingCall &other) noexcept { qSwap(d, other.d); } + void swap(QDBusPendingCall &other) noexcept { d.swap(other.d); } #ifndef Q_CLANG_QDOC // pretend that they aren't here diff --git a/src/dbus/qdbusunixfiledescriptor.h b/src/dbus/qdbusunixfiledescriptor.h index a2da2c52da..b94c17dc0b 100644 --- a/src/dbus/qdbusunixfiledescriptor.h +++ b/src/dbus/qdbusunixfiledescriptor.h @@ -64,7 +64,7 @@ public: ~QDBusUnixFileDescriptor(); void swap(QDBusUnixFileDescriptor &other) noexcept - { qSwap(d, other.d); } + { d.swap(other.d); } bool isValid() const; |