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. b1b0c2970e
.
Pick-to: 6.3 6.2
Task-number: QTBUG-97601
Change-Id: I987ff95e8751a22a4f283655d8225dd16de21178
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
81fb9c5b14
commit
c839efb07a
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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:
|
||||
|
@ -90,7 +90,7 @@ public:
|
||||
QCursor(QCursor &&other) noexcept : d(qExchange(other.d, nullptr)) {}
|
||||
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QCursor)
|
||||
|
||||
void swap(QCursor &other) noexcept { qSwap(d, other.d); }
|
||||
void swap(QCursor &other) noexcept { qt_ptr_swap(d, other.d); }
|
||||
|
||||
operator QVariant() const;
|
||||
|
||||
|
@ -102,7 +102,7 @@ public:
|
||||
bool operator!=(const QEventPoint &other) const noexcept { return !operator==(other); }
|
||||
~QEventPoint();
|
||||
inline void swap(QEventPoint &other) noexcept
|
||||
{ qSwap(d, other.d); }
|
||||
{ d.swap(other.d); }
|
||||
|
||||
QPointF position() const;
|
||||
QPointF pressPosition() const;
|
||||
|
@ -186,7 +186,7 @@ public:
|
||||
QKeyCombination operator[](uint i) const;
|
||||
QKeySequence &operator=(const QKeySequence &other);
|
||||
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QKeySequence)
|
||||
void swap(QKeySequence &other) noexcept { qSwap(d, other.d); }
|
||||
void swap(QKeySequence &other) noexcept { qt_ptr_swap(d, other.d); }
|
||||
|
||||
bool operator==(const QKeySequence &other) const;
|
||||
inline bool operator!= (const QKeySequence &other) const
|
||||
|
@ -74,8 +74,8 @@ public:
|
||||
|
||||
void swap(QPalette &other) noexcept
|
||||
{
|
||||
qSwap(currentGroup, other.currentGroup);
|
||||
qSwap(d, other.d);
|
||||
std::swap(currentGroup, other.currentGroup);
|
||||
qt_ptr_swap(d, other.d);
|
||||
}
|
||||
|
||||
operator QVariant() const;
|
||||
|
@ -83,7 +83,7 @@ public:
|
||||
QBrush &operator=(const QBrush &brush);
|
||||
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QBrush)
|
||||
inline void swap(QBrush &other) noexcept
|
||||
{ qSwap(d, other.d); }
|
||||
{ d.swap(other.d); }
|
||||
|
||||
operator QVariant() const;
|
||||
|
||||
|
@ -112,7 +112,7 @@ public:
|
||||
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QColorSpace)
|
||||
|
||||
void swap(QColorSpace &colorSpace) noexcept
|
||||
{ qSwap(d_ptr, colorSpace.d_ptr); }
|
||||
{ d_ptr.swap(colorSpace.d_ptr); }
|
||||
|
||||
Primaries primaries() const noexcept;
|
||||
TransferFunction transferFunction() const noexcept;
|
||||
|
@ -85,7 +85,7 @@ public:
|
||||
QPageLayout &operator=(const QPageLayout &other);
|
||||
~QPageLayout();
|
||||
|
||||
void swap(QPageLayout &other) noexcept { qSwap(d, other.d); }
|
||||
void swap(QPageLayout &other) noexcept { d.swap(other.d); }
|
||||
|
||||
bool isEquivalentTo(const QPageLayout &other) const;
|
||||
|
||||
|
@ -65,7 +65,7 @@ public:
|
||||
QPageRanges(QPageRanges &&other) noexcept = default;
|
||||
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPageRanges)
|
||||
void swap(QPageRanges &other) noexcept
|
||||
{ qSwap(d, other.d); }
|
||||
{ d.swap(other.d); }
|
||||
|
||||
friend bool operator==(const QPageRanges &lhs, const QPageRanges &rhs) noexcept
|
||||
{ return lhs.isEqual(rhs); }
|
||||
|
@ -237,7 +237,7 @@ public:
|
||||
~QPageSize();
|
||||
|
||||
|
||||
void swap(QPageSize &other) noexcept { qSwap(d, other.d); }
|
||||
void swap(QPageSize &other) noexcept { d.swap(other.d); }
|
||||
|
||||
friend Q_GUI_EXPORT bool operator==(const QPageSize &lhs, const QPageSize &rhs);
|
||||
bool isEquivalentTo(const QPageSize &other) const;
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
QPen(QPen &&other) noexcept
|
||||
: d(qExchange(other.d, nullptr)) {}
|
||||
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPen)
|
||||
void swap(QPen &other) noexcept { qSwap(d, other.d); }
|
||||
void swap(QPen &other) noexcept { qt_ptr_swap(d, other.d); }
|
||||
|
||||
Qt::PenStyle style() const;
|
||||
void setStyle(Qt::PenStyle);
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
~QRegion();
|
||||
QRegion &operator=(const QRegion &);
|
||||
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QRegion)
|
||||
inline void swap(QRegion &other) noexcept { qSwap(d, other.d); }
|
||||
void swap(QRegion &other) noexcept { qt_ptr_swap(d, other.d); }
|
||||
bool isEmpty() const;
|
||||
bool isNull() const;
|
||||
|
||||
|
@ -174,8 +174,8 @@ public:
|
||||
QFont(const QFont &font);
|
||||
~QFont();
|
||||
|
||||
void swap(QFont &other)
|
||||
{ qSwap(d, other.d); qSwap(resolve_mask, other.resolve_mask); }
|
||||
void swap(QFont &other) noexcept
|
||||
{ d.swap(other.d); std::swap(resolve_mask, other.resolve_mask); }
|
||||
|
||||
QString family() const;
|
||||
void setFamily(const QString &);
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
|
||||
QFontInfo &operator=(const QFontInfo &);
|
||||
|
||||
void swap(QFontInfo &other) { qSwap(d, other.d); }
|
||||
void swap(QFontInfo &other) noexcept { d.swap(other.d); }
|
||||
|
||||
QString family() const;
|
||||
QString styleName() const;
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QFontMetrics)
|
||||
|
||||
void swap(QFontMetrics &other) noexcept
|
||||
{ qSwap(d, other.d); }
|
||||
{ d.swap(other.d); }
|
||||
|
||||
int ascent() const;
|
||||
int capHeight() const;
|
||||
@ -136,7 +136,7 @@ public:
|
||||
QFontMetricsF &operator=(const QFontMetrics &);
|
||||
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QFontMetricsF)
|
||||
|
||||
void swap(QFontMetricsF &other) noexcept { qSwap(d, other.d); }
|
||||
void swap(QFontMetricsF &other) noexcept { d.swap(other.d); }
|
||||
|
||||
qreal ascent() const;
|
||||
qreal capHeight() const;
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
QGlyphRun &operator=(const QGlyphRun &other);
|
||||
~QGlyphRun();
|
||||
|
||||
void swap(QGlyphRun &other) noexcept { qSwap(d, other.d); }
|
||||
void swap(QGlyphRun &other) noexcept { d.swap(other.d); }
|
||||
|
||||
QRawFont rawFont() const;
|
||||
void setRawFont(const QRawFont &rawFont);
|
||||
|
@ -83,7 +83,7 @@ public:
|
||||
QRawFont &operator=(const QRawFont &other);
|
||||
~QRawFont();
|
||||
|
||||
void swap(QRawFont &other) noexcept { qSwap(d, other.d); }
|
||||
void swap(QRawFont &other) noexcept { d.swap(other.d); }
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
QStaticText &operator=(const QStaticText &);
|
||||
~QStaticText();
|
||||
|
||||
void swap(QStaticText &other) noexcept { qSwap(data, other.data); }
|
||||
void swap(QStaticText &other) noexcept { data.swap(other.data); }
|
||||
|
||||
void setText(const QString &text);
|
||||
QString text() const;
|
||||
|
@ -77,7 +77,7 @@ public:
|
||||
QTextCursor &operator=(const QTextCursor &other);
|
||||
~QTextCursor();
|
||||
|
||||
void swap(QTextCursor &other) noexcept { qSwap(d, other.d); }
|
||||
void swap(QTextCursor &other) noexcept { d.swap(other.d); }
|
||||
|
||||
bool isNull() const;
|
||||
|
||||
|
@ -320,7 +320,7 @@ public:
|
||||
~QTextFormat();
|
||||
|
||||
void swap(QTextFormat &other)
|
||||
{ qSwap(d, other.d); qSwap(format_type, other.format_type); }
|
||||
{ d.swap(other.d); std::swap(format_type, other.format_type); }
|
||||
|
||||
void merge(const QTextFormat &other);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user