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/qsimplex_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/qsimplex_p.cpp')
-rw-r--r-- | src/widgets/graphicsview/qsimplex_p.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/widgets/graphicsview/qsimplex_p.cpp b/src/widgets/graphicsview/qsimplex_p.cpp index b827ab1400..d4e2e2f922 100644 --- a/src/widgets/graphicsview/qsimplex_p.cpp +++ b/src/widgets/graphicsview/qsimplex_p.cpp @@ -153,9 +153,11 @@ bool QSimplex::setConstraints(const QList<QSimplexConstraint *> &newConstraints) // "variables" is a list that provides a stable, indexed list of all variables // used in this problem. QSet<QSimplexVariable *> variablesSet; - for (int i = 0; i < constraints.size(); ++i) - variablesSet += \ - QSet<QSimplexVariable *>::fromList(constraints[i]->variables.keys()); + for (int i = 0; i < constraints.size(); ++i) { + const auto &v = constraints.at(i)->variables; + for (auto it = v.cbegin(), end = v.cend(); it != end; ++it) + variablesSet.insert(it.key()); + } variables = variablesSet.toList(); // Set Variables reverse mapping |