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>
This commit is contained in:
Marc Mutz 2015-06-22 11:30:48 +02:00
parent 27de4ea4d6
commit dcd79eebdb

View File

@ -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
{