Skip to content

Commit

Permalink
QtWidgets benchmarks: port remaining users away from Q_FOREACH
Browse files Browse the repository at this point in the history
These are all trivial: all are over (already or newly-made) const
local variables.

We don't have a mechanism to mark a subtree as Q_FOREACH-free, and
adding QT_NO_FOREACH to each executable is overkill, so we just have
to hope that no new uses are being introduced until we can mark the
whole QtBase module as Q_FOREACH-free.

Pick-to: 6.6 6.5
Task-number: QTBUG-115803
Change-Id: I13dc176756633674bab8c93a342ecdba6c5dd23e
Reviewed-by: Ahmad Samir <[email protected]>
Reviewed-by: Fabian Kosmale <[email protected]>
Reviewed-by: Joerg Bornemann <[email protected]>
  • Loading branch information
marcmutz authored and Ahmad Samir committed Aug 14, 2023
1 parent 5d8db91 commit d4ba159
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ void AbstractScrollArea::setViewport(QGraphicsWidget *viewport)
if (m_viewport) {
m_viewport->setParentItem(0);

QList<QGraphicsItem*> children = m_viewport->childItems();
const QList<QGraphicsItem*> children = m_viewport->childItems();

foreach (QGraphicsItem *child, children)
for (QGraphicsItem *child : children)
child->setParentItem(0);

delete m_viewport;
Expand Down
16 changes: 8 additions & 8 deletions tests/benchmarks/widgets/itemviews/qtableview/tst_qtableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,13 @@ void tst_QTableView::rowInsertion_data()

void tst_QTableView::rowInsertion()
{
QFETCH(SpanList, spans);
QFETCH(const SpanList, spans);

QtTestTableModel model(10, 10);
QTableView view;
view.setModel(&model);

foreach (QRect span, spans)
for (QRect span : spans)
view.setSpan(span.top(), span.left(), span.height(), span.width());
view.show();
QTest::qWait(50);
Expand All @@ -259,13 +259,13 @@ void tst_QTableView::rowRemoval_data()

void tst_QTableView::rowRemoval()
{
QFETCH(SpanList, spans);
QFETCH(const SpanList, spans);

QtTestTableModel model(10, 10);
QTableView view;
view.setModel(&model);

foreach (QRect span, spans)
for (QRect span : spans)
view.setSpan(span.top(), span.left(), span.height(), span.width());
view.show();
QTest::qWait(50);
Expand All @@ -282,14 +282,14 @@ void tst_QTableView::columnInsertion_data()

void tst_QTableView::columnInsertion()
{
QFETCH(SpanList, spans);
QFETCH(const SpanList, spans);

QtTestTableModel model(10, 10);
QTableView view;
view.setModel(&model);

// Same set as for rowInsertion, just swapping columns and rows.
foreach (QRect span, spans)
for (QRect span : spans)
view.setSpan(span.left(), span.top(), span.width(), span.height());
view.show();
QTest::qWait(50);
Expand All @@ -309,14 +309,14 @@ void tst_QTableView::columnRemoval_data()

void tst_QTableView::columnRemoval()
{
QFETCH(SpanList, spans);
QFETCH(const SpanList, spans);

QtTestTableModel model(10, 10);
QTableView view;
view.setModel(&model);

// Same set as for rowRemoval, just swapping columns and rows.
foreach (QRect span, spans)
for (QRect span : spans)
view.setSpan(span.left(), span.top(), span.width(), span.height());
view.show();
QTest::qWait(50);
Expand Down

0 comments on commit d4ba159

Please sign in to comment.