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:
Marc Mutz 2012-03-01 10:09:02 +01:00 committed by Qt by Nokia
parent e2f8cdf9a6
commit a03a71e332
5 changed files with 7 additions and 10 deletions

View File

@ -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()

View File

@ -62,7 +62,7 @@ protected:
private:
int x, y;
QColor color;
QList<QPointF> stuff;
QVector<QPointF> stuff;
};
#endif

View File

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

View File

@ -62,7 +62,7 @@ protected:
private:
int x, y;
QColor color;
QList<QPointF> stuff;
QVector<QPointF> stuff;
};
#endif

View File

@ -62,7 +62,7 @@ protected:
private:
int x, y;
QColor color;
QList<QPointF> stuff;
QVector<QPointF> stuff;
};
#endif