summaryrefslogtreecommitdiffstats
path: root/src/widgets/graphicsview
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2013-10-06 22:50:12 +0200
committerMarc Mutz <marc.mutz@kdab.com>2016-01-18 10:34:24 +0000
commitea76ab2b2ded0197ddf9e33e8d6a8af909fce31c (patch)
tree550b08d1e6be098dda312551c5465fd9fd26793f /src/widgets/graphicsview
parentb30ea419450c968c009ddcae964b1b54755f11ac (diff)
QtWidgets: replace uses of inefficient QList<QPair>s with QVectors
These QPairs 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 holding them in QVector instead. Change-Id: I3c205f5326cfd96482563078bdca1747d718457f Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/widgets/graphicsview')
-rw-r--r--src/widgets/graphicsview/qgraph_p.h4
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp6
2 files changed, 5 insertions, 5 deletions
diff --git a/src/widgets/graphicsview/qgraph_p.h b/src/widgets/graphicsview/qgraph_p.h
index 34c6a8c3c5..14f7122d5c 100644
--- a/src/widgets/graphicsview/qgraph_p.h
+++ b/src/widgets/graphicsview/qgraph_p.h
@@ -211,8 +211,8 @@ public:
return setOfVertices;
}
- QList<QPair<Vertex*, Vertex*> > connections() const {
- QList<QPair<Vertex*, Vertex*> > conns;
+ QVector<QPair<Vertex*, Vertex*> > connections() const {
+ QVector<QPair<Vertex*, Vertex*> > conns;
for (const_iterator it = constBegin(); it != constEnd(); ++it) {
Vertex *from = it.from();
Vertex *to = it.to();
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
index b5865ec9c9..1e5aea9688 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -1266,7 +1266,7 @@ void QGraphicsAnchorLayoutPrivate::restoreSimplifiedGraph(Orientation orientatio
// Restore anchor simplification
Graph<AnchorVertex, AnchorData> &g = graph[orientation];
- QList<QPair<AnchorVertex*, AnchorVertex*> > connections = g.connections();
+ QVector<QPair<AnchorVertex*, AnchorVertex*> > connections = g.connections();
for (int i = 0; i < connections.count(); ++i) {
AnchorVertex *v1 = connections.at(i).first;
AnchorVertex *v2 = connections.at(i).second;
@@ -2295,7 +2295,7 @@ bool QGraphicsAnchorLayoutPrivate::calculateNonTrunk(const QList<QSimplexConstra
void QGraphicsAnchorLayoutPrivate::refreshAllSizeHints(Orientation orientation)
{
Graph<AnchorVertex, AnchorData> &g = graph[orientation];
- QList<QPair<AnchorVertex *, AnchorVertex *> > vertices = g.connections();
+ QVector<QPair<AnchorVertex *, AnchorVertex *> > vertices = g.connections();
QLayoutStyleInfo styleInf = styleInfo();
for (int i = 0; i < vertices.count(); ++i) {
@@ -2388,7 +2388,7 @@ void QGraphicsAnchorLayoutPrivate::constraintsFromPaths(Orientation orientation)
void QGraphicsAnchorLayoutPrivate::updateAnchorSizes(Orientation orientation)
{
Graph<AnchorVertex, AnchorData> &g = graph[orientation];
- const QList<QPair<AnchorVertex *, AnchorVertex *> > &vertices = g.connections();
+ const QVector<QPair<AnchorVertex *, AnchorVertex *> > &vertices = g.connections();
for (int i = 0; i < vertices.count(); ++i) {
AnchorData *ad = g.edgeData(vertices.at(i).first, vertices.at(i).second);