diff options
author | Sérgio Martins <sergio.martins@kdab.com> | 2015-06-22 22:12:27 +0100 |
---|---|---|
committer | Sérgio Martins <sergio.martins@kdab.com> | 2015-06-23 15:35:59 +0000 |
commit | fece7cdb5daed826ab074b3210327dcfd7ab0e90 (patch) | |
tree | 05b99df28e5fb65a81397a9464ad977027559322 /src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp | |
parent | a4d3af961445995337c279e71c861afc213c06f3 (diff) |
widgets: Use QList::reserve(), reduces reallocations.
Change-Id: I49cc03f365c77f142f62c8e77505ec09723a44d9
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp')
-rw-r--r-- | src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp index 8327777217..ce9344e2d9 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp @@ -752,8 +752,10 @@ static AnchorData *createSequence(Graph<AnchorVertex, AnchorData> *graph, AnchorVertex *prev = before; QVector<AnchorData *> edges; + const int numVertices = vertices.count(); + edges.reserve(numVertices + 1); // Take from the graph, the edges that will be simplificated - for (int i = 0; i < vertices.count(); ++i) { + for (int i = 0; i < numVertices; ++i) { AnchorVertex *next = vertices.at(i); AnchorData *ad = graph->takeEdge(prev, next); Q_ASSERT(ad); @@ -2569,6 +2571,7 @@ QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation) if (!remainingConstraints.isEmpty()) { QList<QSimplexConstraint *> nonTrunkConstraints; + nonTrunkConstraints.reserve(remainingConstraints.size()); QLinkedList<QSimplexConstraint *>::iterator it = remainingConstraints.begin(); while (it != remainingConstraints.end()) { nonTrunkConstraints += *it; |