diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-12-15 20:42:21 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-12-16 17:42:29 +0000 |
commit | 4891fd02c5503e6f3838276883f7bba0b89cdb0d (patch) | |
tree | 9d2b1026c64422d768dbbd8c53409fdcb646ec15 /src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp | |
parent | f2d8d9daee9ecb046750bd340288b8d3da2224ed (diff) |
QGraphicsAnchorLayout: replace three loops over QHash::keys() with QHash::const_iterator loops
Quite obviously faster (doesn't need to populate a QList first,
just to iterate over it).
Also saves 1.5KiB text on optimized GCC 4.9 Linux AMD64 builds.
Change-Id: If4c7af80165a6027d39359bac22df30e7ca09815
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp')
-rw-r--r-- | src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp index 1c63ed5243..e16b427448 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp @@ -2058,9 +2058,8 @@ QList<AnchorData *> getVariables(const QList<QSimplexConstraint *> &constraints) QSet<AnchorData *> variableSet; for (int i = 0; i < constraints.count(); ++i) { const QSimplexConstraint *c = constraints.at(i); - foreach (QSimplexVariable *var, c->variables.keys()) { - variableSet += static_cast<AnchorData *>(var); - } + for (auto it = c->variables.cbegin(), end = c->variables.cend(); it != end; ++it) + variableSet.insert(static_cast<AnchorData *>(it.key())); } return variableSet.toList(); } @@ -2546,7 +2545,8 @@ QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation) // remaining constraints. if (match) { trunkConstraints += c; - trunkVariables += QSet<QSimplexVariable *>::fromList(c->variables.keys()); + for (auto jt = c->variables.cbegin(), end = c->variables.cend(); jt != end; ++jt) + trunkVariables.insert(jt.key()); it = remainingConstraints.erase(it); dirty = true; } else { |