summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-01-14 11:23:31 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-01-19 12:58:22 +0000
commitf7ac5968fc92d9c656b4c2f742ee8245a9692bb4 (patch)
tree4dbaddc3442c2e9fb5b1dd072d9f142002634411 /src/gui
parent49e263ef4b1f5e03012a64ec137f3f3fc540ca9b (diff)
QPolygon: de-inline setPoint()
In Qt 5 times, the core of QList::realloc() was out-of-line by design, because it was independent of T. Now that QList is QVector, its equivalent detachAndGrow() function on QArrayDataPointer is inline and instantiated for each type anew. We therefore need to be careful to not use detach()ing QList operations in non-generic code inline code (in public, but also private, headers), because (common) PCH builds force this code to be compiled over and over again. Generic code is only instantiated when used in a TU, so that's ok. But for non-generic code, the only option is to de-inline. If there is an effect on compile-times, it's hidden in the run-by-run noise of building QtGui, but at least this entry is gone afterwards from clang -ftime-trace: **** Templates that took longest to instantiate: [...] 4676 ms: QList<QPoint>::operator[] (261 times, avg 17 ms) Added 'inline' to the definition of the setPoint(int, QPoint) overload, since MinGW used to complain about it missing. Task-number: QTBUG-97601 Pick-to: 6.3 Change-Id: Ie6f67da7ef39a16c98a7451d37b6d96531656392 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/painting/qpolygon.cpp7
-rw-r--r--src/gui/painting/qpolygon.h9
2 files changed, 8 insertions, 8 deletions
diff --git a/src/gui/painting/qpolygon.cpp b/src/gui/painting/qpolygon.cpp
index d601dcdb0c..f124691f02 100644
--- a/src/gui/painting/qpolygon.cpp
+++ b/src/gui/painting/qpolygon.cpp
@@ -263,13 +263,16 @@ void QPolygon::point(int index, int *x, int *y) const
*/
/*!
- \fn void QPolygon::setPoint(int index, int x, int y)
-
Sets the point at the given \a index to the point specified by
(\a{x}, \a{y}).
\sa point(), putPoints(), setPoints(),
*/
+void QPolygon::setPoint(int index, int x, int y)
+{
+ (*this)[index] = QPoint(x, y);
+}
+
/*!
Resizes the polygon to \a nPoints and populates it with the given
diff --git a/src/gui/painting/qpolygon.h b/src/gui/painting/qpolygon.h
index a8997c5e3d..f7153a9f37 100644
--- a/src/gui/painting/qpolygon.h
+++ b/src/gui/painting/qpolygon.h
@@ -76,8 +76,8 @@ public:
Q_GUI_EXPORT void point(int i, int *x, int *y) const;
QPoint point(int i) const;
- void setPoint(int index, int x, int y);
- void setPoint(int index, const QPoint &p);
+ Q_GUI_EXPORT void setPoint(int index, int x, int y);
+ inline void setPoint(int index, const QPoint &p);
Q_GUI_EXPORT void setPoints(int nPoints, const int *points);
Q_GUI_EXPORT void setPoints(int nPoints, int firstx, int firsty, ...);
Q_GUI_EXPORT void putPoints(int index, int nPoints, const int *points);
@@ -111,10 +111,7 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QPolygon &polygon);
*****************************************************************************/
inline void QPolygon::setPoint(int index, const QPoint &pt)
-{ (*this)[index] = pt; }
-
-inline void QPolygon::setPoint(int index, int x, int y)
-{ (*this)[index] = QPoint(x, y); }
+{ setPoint(index, pt.x(), pt.y()); }
inline QPoint QPolygon::point(int index) const
{ return at(index); }