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:
parent
27de4ea4d6
commit
dcd79eebdb
@ -132,10 +132,12 @@ public:
|
|||||||
int preferredSize;
|
int preferredSize;
|
||||||
bool gap;
|
bool gap;
|
||||||
};
|
};
|
||||||
|
Q_DECLARE_TYPEINFO(QToolBarAreaLayoutItem, Q_PRIMITIVE_TYPE);
|
||||||
|
|
||||||
class QToolBarAreaLayoutLine
|
class QToolBarAreaLayoutLine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
QToolBarAreaLayoutLine() {} // for QVector, don't use
|
||||||
QToolBarAreaLayoutLine(Qt::Orientation orientation);
|
QToolBarAreaLayoutLine(Qt::Orientation orientation);
|
||||||
|
|
||||||
QSize sizeHint() const;
|
QSize sizeHint() const;
|
||||||
@ -147,16 +149,15 @@ public:
|
|||||||
QRect rect;
|
QRect rect;
|
||||||
Qt::Orientation o;
|
Qt::Orientation o;
|
||||||
|
|
||||||
QList<QToolBarAreaLayoutItem> toolBarItems;
|
QVector<QToolBarAreaLayoutItem> toolBarItems;
|
||||||
};
|
};
|
||||||
|
Q_DECLARE_TYPEINFO(QToolBarAreaLayoutLine, Q_MOVABLE_TYPE);
|
||||||
|
|
||||||
class QToolBarAreaLayoutInfo
|
class QToolBarAreaLayoutInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QToolBarAreaLayoutInfo(QInternal::DockPosition pos = QInternal::TopDock);
|
QToolBarAreaLayoutInfo(QInternal::DockPosition pos = QInternal::TopDock);
|
||||||
|
|
||||||
QList<QToolBarAreaLayoutLine> lines;
|
|
||||||
|
|
||||||
QSize sizeHint() const;
|
QSize sizeHint() const;
|
||||||
QSize minimumSize() const;
|
QSize minimumSize() const;
|
||||||
|
|
||||||
@ -175,11 +176,13 @@ public:
|
|||||||
QRect itemRect(const QList<int> &path) const;
|
QRect itemRect(const QList<int> &path) const;
|
||||||
int distance(const QPoint &pos) const;
|
int distance(const QPoint &pos) const;
|
||||||
|
|
||||||
|
QVector<QToolBarAreaLayoutLine> lines;
|
||||||
QRect rect;
|
QRect rect;
|
||||||
Qt::Orientation o;
|
Qt::Orientation o;
|
||||||
QInternal::DockPosition dockPos;
|
QInternal::DockPosition dockPos;
|
||||||
bool dirty;
|
bool dirty;
|
||||||
};
|
};
|
||||||
|
Q_DECLARE_TYPEINFO(QToolBarAreaLayoutInfo, Q_MOVABLE_TYPE);
|
||||||
|
|
||||||
class QToolBarAreaLayout
|
class QToolBarAreaLayout
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user