From 62312e667441aea32ebaf70f1304d3fb0381f48f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 5 Aug 2023 19:15:17 +0200 Subject: [PATCH] GraphicsViewBenchmark: port from QList/Q_FOREACH to initializer_list/ranged-for This is more readable and at the same time helps to eradicate some more Q_FOREACH uses for an eventual global QT_NO_FOREACH for all Qt sources (QTBUG-115796). Task-number: QTBUG-115803 Change-Id: I9cbe76bee8a6306fab0c0bc94cd874405ca825ba Reviewed-by: Ahmad Samir Reviewed-by: Ivan Solovev --- .../functional/GraphicsViewBenchmark/main.cpp | 45 ++++--------------- 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/main.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/main.cpp index 9b31bf88dbb..ce0c683f2d6 100644 --- a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/main.cpp +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/main.cpp @@ -541,23 +541,11 @@ void tst_GraphicsViewBenchmark::update_data() QTest::addColumn("subtreeCache"); QTest::addColumn("rotationAngle"); - QList listTypes; - listTypes << Simple << Recycling; - - QList listSizes; - listSizes << 10 << 50 << 500; - - QList themes; - themes << Theme::Blue << Theme::Lime; - - QList rotationAngles; - rotationAngles << 0 << 90; - // Generate rows: - foreach (ListType listType, listTypes) { - foreach (int listSize, listSizes) { - foreach (int angle, rotationAngles) { - foreach (Theme::Themes theme, themes) { + for (ListType listType : {Simple, Recycling}) { + for (int listSize : {10, 50, 500}) { + for (int angle : {0, 90}) { + for (Theme::Themes theme : {Theme::Blue, Theme::Lime}) { for (int toImage = 0; toImage < 2; ++toImage) { for (int cache = 0; cache < 2; ++cache) { QString string = rowString(listSize, listType, theme, toImage, cache, angle); @@ -613,27 +601,12 @@ void tst_GraphicsViewBenchmark::scroll_data() QTest::addColumn("rotationAngle"); QTest::addColumn("scrollStep"); - QList listTypes; - listTypes << Simple << Recycling; - - QList listSizes; - listSizes << 10 << 50 << 500; - - QList themes; - themes << Theme::Blue << Theme::Lime; - - QList rotationAngles; - rotationAngles << 0 << 90; - - QList scrollSteps; - scrollSteps << Slow << Normal << Fast; - // Generate rows: - foreach (ListType listType, listTypes) { - foreach (int listSize, listSizes) { - foreach (int angle, rotationAngles) { - foreach (ScrollStep step, scrollSteps) { - foreach (Theme::Themes theme, themes) { + for (ListType listType : {Simple, Recycling}) { + for (int listSize : {10, 50, 500}) { + for (int angle : {0, 90}) { + for (ScrollStep step : {Slow, Normal, Fast}) { + for (Theme::Themes theme : {Theme::Blue, Theme::Lime}) { for (int cache = 0; cache < 2; ++cache) { QString string = rowString(listSize, listType, theme, cache, angle, step); QTest::newRow(string.toLatin1()) << listSize << listType << theme