Rest of QtBase: 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

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: I53e031a021031d53a74a712cd0f5e6bb8bf800bd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
bb10
Marc Mutz 2022-03-15 21:20:46 +01:00
parent f438d29b6f
commit 60592f72d6
4 changed files with 6 additions and 8 deletions

View File

@ -112,7 +112,7 @@ public:
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QOpenGLDebugMessage)
~QOpenGLDebugMessage();
void swap(QOpenGLDebugMessage &other) noexcept { qSwap(d, other.d); }
void swap(QOpenGLDebugMessage &other) noexcept { d.swap(other.d); }
Source source() const;
Type type() const;

View File

@ -70,7 +70,7 @@ public:
bool operator!=(const QSqlError& other) const;
~QSqlError();
void swap(QSqlError &other) noexcept { qSwap(d, other.d); }
void swap(QSqlError &other) noexcept { qt_ptr_swap(d, other.d); }
QString driverText() const;
QString databaseText() const;

View File

@ -80,9 +80,7 @@ public:
~QSqlQuery();
void swap(QSqlQuery &other) noexcept
{
qSwap(d, other.d);
}
{ qt_ptr_swap(d, other.d); }
bool isValid() const;
bool isActive() const;

View File

@ -60,9 +60,9 @@ public:
void swap(QSqlRelation &other) noexcept
{
qSwap(tName, other.tName);
qSwap(iColumn, other.iColumn);
qSwap(dColumn, other.dColumn);
tName.swap(other.tName);
iColumn.swap(other.iColumn);
dColumn.swap(other.dColumn);
}
inline QString tableName() const