summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2012-03-01 10:09:02 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-08 05:31:40 +0100
commita03a71e332294aa500ac8475bb777c2f33609e8b (patch)
treee34b460ad45825c9accb48b79ad72dde44c707f7
parente2f8cdf9a637d88d43fbd3f5a174ba81051ee975 (diff)
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>
-rw-r--r--examples/animation/stickman/animation.cpp9
-rw-r--r--examples/graphicsview/chip/chip.h2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp2
-rw-r--r--tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/chip.h2
-rw-r--r--tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chip.h2
5 files changed, 7 insertions, 10 deletions
diff --git a/examples/animation/stickman/animation.cpp b/examples/animation/stickman/animation.cpp
index 4469b365de..afdfae6eca 100644
--- a/examples/animation/stickman/animation.cpp
+++ b/examples/animation/stickman/animation.cpp
@@ -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()
diff --git a/examples/graphicsview/chip/chip.h b/examples/graphicsview/chip/chip.h
index 04fae2d30c..4c1cfae37d 100644
--- a/examples/graphicsview/chip/chip.h
+++ b/examples/graphicsview/chip/chip.h
@@ -62,7 +62,7 @@ protected:
private:
int x, y;
QColor color;
- QList<QPointF> stuff;
+ QVector<QPointF> stuff;
};
#endif
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
index 220c89ec2f..daa06d0762 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -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)
diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/chip.h b/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/chip.h
index b13f4a11e1..d2d859b402 100644
--- a/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/chip.h
+++ b/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/chip.h
@@ -62,7 +62,7 @@ protected:
private:
int x, y;
QColor color;
- QList<QPointF> stuff;
+ QVector<QPointF> stuff;
};
#endif
diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chip.h b/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chip.h
index ef3550e8d7..462109e599 100644
--- a/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chip.h
+++ b/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chip.h
@@ -62,7 +62,7 @@ protected:
private:
int x, y;
QColor color;
- QList<QPointF> stuff;
+ QVector<QPointF> stuff;
};
#endif