QTextEngine: don't hold ItemDecoration in QList
ItemDecoration is larger than a void*, so holding it 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 type movable and holding in QVector instead. Change-Id: I06d7a77529f7cff2ba503c5e8d6e5df0ad801a21 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
This commit is contained in:
parent
f5243c0591
commit
a082b41d2c
@ -400,6 +400,7 @@ public:
|
||||
};
|
||||
|
||||
struct ItemDecoration {
|
||||
ItemDecoration() {} // for QVector, don't use
|
||||
ItemDecoration(qreal x1, qreal x2, qreal y, const QPen &pen):
|
||||
x1(x1), x2(x2), y(y), pen(pen) {}
|
||||
|
||||
@ -409,7 +410,7 @@ public:
|
||||
QPen pen;
|
||||
};
|
||||
|
||||
typedef QList<ItemDecoration> ItemDecorationList;
|
||||
typedef QVector<ItemDecoration> ItemDecorationList;
|
||||
|
||||
QTextEngine();
|
||||
QTextEngine(const QString &str, const QFont &f);
|
||||
@ -643,6 +644,7 @@ public:
|
||||
LayoutData _layoutData;
|
||||
void *_memory[MemSize];
|
||||
};
|
||||
Q_DECLARE_TYPEINFO(QTextEngine::ItemDecoration, Q_MOVABLE_TYPE);
|
||||
|
||||
struct QTextLineItemIterator
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user