From e459130e70b7c60ad3a768b09a581999458906e0 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Fri, 12 Jan 2018 18:03:27 +0000 Subject: qstylesheet: remove a few unneeded memory allocations One foreach too many, creating a temporary container. Converted to range-loop, as drive-by change. Change-Id: Ie2bb94a7147edcfc0d8b5f479604f5ebe113d7cb Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/styles/qstylesheetstyle.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 25ee085f30..7c553a9e1c 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -2692,24 +2692,19 @@ void QStyleSheetStyle::unsetStyleSheetFont(QWidget *w) const static void updateObjects(const QList& objects) { if (!styleSheetCaches->styleRulesCache.isEmpty() || !styleSheetCaches->hasStyleRuleCache.isEmpty() || !styleSheetCaches->renderRulesCache.isEmpty()) { - for (int i = 0; i < objects.size(); ++i) { - const QObject *object = objects.at(i); + for (const QObject *object : objects) { styleSheetCaches->styleRulesCache.remove(object); styleSheetCaches->hasStyleRuleCache.remove(object); styleSheetCaches->renderRulesCache.remove(object); } } - QWidgetList widgets; - foreach (const QObject *object, objects) { - if (QWidget *w = qobject_cast(const_cast(object))) - widgets << w; - } - QEvent event(QEvent::StyleChange); - foreach (QWidget *widget, widgets) { - widget->style()->polish(widget); - QApplication::sendEvent(widget, &event); + for (const QObject *object : objects) { + if (auto widget = qobject_cast(const_cast(object))) { + widget->style()->polish(widget); + QApplication::sendEvent(widget, &event); + } } } -- cgit v1.2.3