From f2d8d9daee9ecb046750bd340288b8d3da2224ed Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 15 Dec 2015 20:37:59 +0100 Subject: [PATCH] QGraphicsAnchorLayout: replace a Q_FOREACH with std::accumulate Saves ~0.5KiB in text size on optimized Linux AMD64 GCC 4.9 builds. Change-Id: Iba2c02eed44f1ee3521bc49fe7afae9c2e916fdc Reviewed-by: Lars Knoll Reviewed-by: Friedemann Kleint --- src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp index 0caff6c678..1c63ed5243 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp @@ -42,6 +42,7 @@ #include #endif +#include #ifndef QT_NO_GRAPHICSVIEW QT_BEGIN_NAMESPACE @@ -2180,10 +2181,7 @@ static void shiftConstraints(const QList &constraints, qre { for (int i = 0; i < constraints.count(); ++i) { QSimplexConstraint *c = constraints.at(i); - qreal multiplier = 0; - foreach (qreal v, c->variables) { - multiplier += v; - } + const qreal multiplier = std::accumulate(c->variables.cbegin(), c->variables.cend(), qreal(0)); c->constant += multiplier * amount; } }