QtWidgets: eradicate Q_FOREACH loops [QVarLengthArray, std containers]

Q_FOREACH over a QVarLengthArray or std containers
is a particularly bad idea (because of the deep
copy that Q_FOREACH then performs).

Use C++11 range-for (without qAsConst(), because
neither QVLA nor std containers are CoW).

Saves 5.7KiB in text size on optimized GCC 5.3
Linux AMD64 builds.

Change-Id: I4c1fb0b488bb08726912528b559840a45c1397df
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
Marc Mutz 2016-02-27 02:56:31 +01:00
parent 1d8030cc64
commit e1c2bfa53b
2 changed files with 4 additions and 4 deletions

View File

@ -427,7 +427,7 @@ QIcon QLineEditPrivate::clearButtonIcon() const
void QLineEditPrivate::setClearButtonEnabled(bool enabled)
{
foreach (const SideWidgetEntry &e, trailingSideWidgets) {
for (const SideWidgetEntry &e : trailingSideWidgets) {
if (e.flags & SideWidgetClearButton) {
e.action->setEnabled(enabled);
break;
@ -443,13 +443,13 @@ void QLineEditPrivate::positionSideWidgets()
const QSize iconSize = QLineEditPrivate::iconSize();
const int delta = QLineEditIconButton::IconMargin + iconSize.width();
QRect widgetGeometry(QPoint(QLineEditIconButton::IconMargin, (contentRect.height() - iconSize.height()) / 2), iconSize);
foreach (const SideWidgetEntry &e, leftSideWidgetList()) {
for (const SideWidgetEntry &e : leftSideWidgetList()) {
e.widget->setGeometry(widgetGeometry);
if (e.action->isVisible())
widgetGeometry.moveLeft(widgetGeometry.left() + delta);
}
widgetGeometry.moveLeft(contentRect.width() - iconSize.width() - QLineEditIconButton::IconMargin);
foreach (const SideWidgetEntry &e, rightSideWidgetList()) {
for (const SideWidgetEntry &e : rightSideWidgetList()) {
e.widget->setGeometry(widgetGeometry);
if (e.action->isVisible())
widgetGeometry.moveLeft(widgetGeometry.left() - delta);

View File

@ -2386,7 +2386,7 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
}
}
}
foreach (QWidget *w, candidates) {
for (QWidget *w : candidates) {
QWindow *handle1 = widget->windowHandle();
QWindow *handle2 = w->windowHandle();
if (handle1 && handle2 && handle1->screen() != handle2->screen())