From c839efb07a6aa3b487dac5f86f905f35ef2c3a08 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 15 Mar 2022 21:20:46 +0100 Subject: QtGui: 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 - 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: I987ff95e8751a22a4f283655d8225dd16de21178 Reviewed-by: Thiago Macieira Reviewed-by: Qt CI Bot Reviewed-by: Volker Hilsheimer --- src/gui/image/qicon.h | 2 +- src/gui/image/qimage.h | 2 +- src/gui/image/qpixmap.h | 2 +- src/gui/image/qpixmapcache.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/gui/image') diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h index fab8c3fe21..d5e192893a 100644 --- a/src/gui/image/qicon.h +++ b/src/gui/image/qicon.h @@ -70,7 +70,7 @@ public: QIcon &operator=(const QIcon &other); QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QIcon) inline void swap(QIcon &other) noexcept - { qSwap(d, other.d); } + { qt_ptr_swap(d, other.d); } bool operator==(const QIcon &) const = delete; bool operator!=(const QIcon &) const = delete; diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 6561359dae..511e1dd864 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -139,7 +139,7 @@ public: QImage &operator=(const QImage &); QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QImage) void swap(QImage &other) noexcept - { qSwap(d, other.d); } + { qt_ptr_swap(d, other.d); } bool isNull() const; diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 9d4d8e582d..e132277421 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -77,7 +77,7 @@ public: QPixmap &operator=(const QPixmap &); QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QPixmap) inline void swap(QPixmap &other) noexcept - { qSwap(data, other.data); } + { data.swap(other.data); } bool operator==(const QPixmap &) const = delete; bool operator!=(const QPixmap &) const = delete; diff --git a/src/gui/image/qpixmapcache.h b/src/gui/image/qpixmapcache.h index 33021d1773..3a273fc3c8 100644 --- a/src/gui/image/qpixmapcache.h +++ b/src/gui/image/qpixmapcache.h @@ -63,7 +63,7 @@ public: { return !operator==(key); } Key &operator =(const Key &other); - void swap(Key &other) noexcept { qSwap(d, other.d); } + void swap(Key &other) noexcept { qt_ptr_swap(d, other.d); } bool isValid() const noexcept; private: -- cgit v1.2.3