diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-06-22 11:30:48 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-02-08 19:57:52 +0000 |
commit | dcd79eebdbcbcb5e67b0456bdef3af8ea4a4dc4f (patch) | |
tree | dc6b82a2e286f27b95a408a04157ed4a86cf871b | |
parent | 27de4ea4d672d9f1b3a733f803f8605f81311d0a (diff) |
QToolBarAreaLayout: replace inefficient QLists with QVector
QToolBarAreaLayout{Item,Line} are larger than a void*, so holding
them in QLists is needlessly inefficient. Worse, the code could
come to depend on the fragile property of (inefficient) QLists
that references to elements therein never are invalidated.
Fix by marking the types primitive and movable, resp., and
holding them in QVector instead.
Change-Id: I4e68d4bee41040bf84302b8ce8295a11debded70
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
-rw-r--r-- | src/widgets/widgets/qtoolbararealayout_p.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/widgets/widgets/qtoolbararealayout_p.h b/src/widgets/widgets/qtoolbararealayout_p.h index 29e836a8f4..a1ae68130c 100644 --- a/src/widgets/widgets/qtoolbararealayout_p.h +++ b/src/widgets/widgets/qtoolbararealayout_p.h @@ -132,10 +132,12 @@ public: int preferredSize; bool gap; }; +Q_DECLARE_TYPEINFO(QToolBarAreaLayoutItem, Q_PRIMITIVE_TYPE); class QToolBarAreaLayoutLine { public: + QToolBarAreaLayoutLine() {} // for QVector, don't use QToolBarAreaLayoutLine(Qt::Orientation orientation); QSize sizeHint() const; @@ -147,16 +149,15 @@ public: QRect rect; Qt::Orientation o; - QList<QToolBarAreaLayoutItem> toolBarItems; + QVector<QToolBarAreaLayoutItem> toolBarItems; }; +Q_DECLARE_TYPEINFO(QToolBarAreaLayoutLine, Q_MOVABLE_TYPE); class QToolBarAreaLayoutInfo { public: QToolBarAreaLayoutInfo(QInternal::DockPosition pos = QInternal::TopDock); - QList<QToolBarAreaLayoutLine> lines; - QSize sizeHint() const; QSize minimumSize() const; @@ -175,11 +176,13 @@ public: QRect itemRect(const QList<int> &path) const; int distance(const QPoint &pos) const; + QVector<QToolBarAreaLayoutLine> lines; QRect rect; Qt::Orientation o; QInternal::DockPosition dockPos; bool dirty; }; +Q_DECLARE_TYPEINFO(QToolBarAreaLayoutInfo, Q_MOVABLE_TYPE); class QToolBarAreaLayout { |