examples: use QVector<QPointF> instead of QList<QPointF>
QPointF is in the category of types for which QList is needlessly inefficient (elements are copy-constructed onto the heap and held through pointers). Use a vector instead. This is consistent with the QPainter API. Change-Id: Id0e910c067a60d12fbc175e7ee7da824834be374 Reviewed-by: hjk <qthjk@ovi.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
parent
e2f8cdf9a6
commit
a03a71e332
@ -41,6 +41,7 @@
|
||||
#include "animation.h"
|
||||
|
||||
#include <QPointF>
|
||||
#include <QVector>
|
||||
#include <QIODevice>
|
||||
#include <QDataStream>
|
||||
|
||||
@ -57,11 +58,7 @@ public:
|
||||
|
||||
void setNodeCount(int nodeCount)
|
||||
{
|
||||
while (nodeCount > m_nodePositions.size())
|
||||
m_nodePositions.append(QPointF());
|
||||
|
||||
while (nodeCount < m_nodePositions.size())
|
||||
m_nodePositions.removeLast();
|
||||
m_nodePositions.resize(nodeCount);
|
||||
}
|
||||
|
||||
QPointF nodePos(int idx) const
|
||||
@ -75,7 +72,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
QList<QPointF> m_nodePositions;
|
||||
QVector<QPointF> m_nodePositions;
|
||||
};
|
||||
|
||||
Animation::Animation()
|
||||
|
@ -62,7 +62,7 @@ protected:
|
||||
private:
|
||||
int x, y;
|
||||
QColor color;
|
||||
QList<QPointF> stuff;
|
||||
QVector<QPointF> stuff;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -2153,7 +2153,7 @@ void tst_QGraphicsScene::mouseEventPropagation_doubleclick()
|
||||
class Scene : public QGraphicsScene
|
||||
{
|
||||
public:
|
||||
QList<QPointF> mouseMovePoints;
|
||||
QVector<QPointF> mouseMovePoints;
|
||||
|
||||
protected:
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
|
@ -62,7 +62,7 @@ protected:
|
||||
private:
|
||||
int x, y;
|
||||
QColor color;
|
||||
QList<QPointF> stuff;
|
||||
QVector<QPointF> stuff;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -62,7 +62,7 @@ protected:
|
||||
private:
|
||||
int x, y;
|
||||
QColor color;
|
||||
QList<QPointF> stuff;
|
||||
QVector<QPointF> stuff;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user