aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlbert Astals Cid <albert.astals.cid@kdab.com>2019-10-04 12:18:50 +0200
committerAlbert Astals Cid <albert.astals.cid@kdab.com>2019-10-04 12:44:51 +0200
commit138f09bd63b8070686ed8a282375dbcf3ce7674f (patch)
treeb4da67121bfcd32fc40c137abc30866ca9c65373
parent4e21daa0210b2aa385792e1c4cb01f57804c5dcb (diff)
Convert a few sizeof(array)/sizeof(element0) fors to range fors
Increases readability Change-Id: I46d82fac83e538988cea79a053d70b954a3cb9f1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--src/qml/jsruntime/qv4dateobject.cpp3
-rw-r--r--src/qml/qml/qqmlimport.cpp8
-rw-r--r--src/quickshapes/qquickshapenvprrenderer.cpp10
3 files changed, 10 insertions, 11 deletions
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp
index 5616b1450b..520b715189 100644
--- a/src/qml/jsruntime/qv4dateobject.cpp
+++ b/src/qml/jsruntime/qv4dateobject.cpp
@@ -601,8 +601,7 @@ static inline double ParseString(const QString &s, double localTZA)
QStringLiteral("d MMMM, yyyy hh:mm:ss"),
};
- for (uint i = 0; i < sizeof(formats) / sizeof(formats[0]); ++i) {
- const QString &format(formats[i]);
+ for (const QString &format : formats) {
dt = format.indexOf(QLatin1String("hh:mm")) < 0
? QDateTime(QDate::fromString(s, format),
QTime(0, 0, 0), Qt::UTC)
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index 5feea9daa8..8b5e11c890 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -780,12 +780,12 @@ bool QQmlImportInstance::resolveType(QQmlTypeLoader *typeLoader, const QHashedSt
typeStr + dotqml_string, // Type -> Type.qml
typeStr + dotuidotqml_string // Type -> Type.ui.qml
};
- for (uint i = 0; i < sizeof(urlsToTry) / sizeof(urlsToTry[0]); ++i) {
- exists = typeLoader->fileExists(localDirectoryPath, urlsToTry[i]);
+ for (const QString &urlToTry : urlsToTry) {
+ exists = typeLoader->fileExists(localDirectoryPath, urlToTry);
if (exists) {
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
// don't let function.qml confuse the use of "new Function(...)" for example.
- if (!QQml_isFileCaseCorrect(localDirectoryPath + urlsToTry[i])) {
+ if (!QQml_isFileCaseCorrect(localDirectoryPath + urlToTry)) {
exists = false;
if (errors) {
QQmlError caseError;
@@ -797,7 +797,7 @@ bool QQmlImportInstance::resolveType(QQmlTypeLoader *typeLoader, const QHashedSt
#else
Q_UNUSED(errors);
#endif
- qmlUrl = url + urlsToTry[i];
+ qmlUrl = url + urlToTry;
break;
}
}
diff --git a/src/quickshapes/qquickshapenvprrenderer.cpp b/src/quickshapes/qquickshapenvprrenderer.cpp
index a5b2a3467c..721091b669 100644
--- a/src/quickshapes/qquickshapenvprrenderer.cpp
+++ b/src/quickshapes/qquickshapenvprrenderer.cpp
@@ -177,7 +177,7 @@ QDebug operator<<(QDebug debug, const QQuickShapeNvprRenderer::NvprPath &path)
debug << "Path with" << path.cmd.count() << "commands";
int ci = 0;
for (GLubyte cmd : path.cmd) {
- static struct { GLubyte cmd; const char *s; int coordCount; } nameTab[] = {
+ static struct { GLubyte cmd; const char *s; int coordCount; } nameTabs[] = {
{ GL_MOVE_TO_NV, "moveTo", 2 },
{ GL_LINE_TO_NV, "lineTo", 2 },
{ GL_QUADRATIC_CURVE_TO_NV, "quadTo", 4 },
@@ -187,14 +187,14 @@ QDebug operator<<(QDebug debug, const QQuickShapeNvprRenderer::NvprPath &path)
{ GL_SMALL_CW_ARC_TO_NV, "arcTo-small-CW", 5 },
{ GL_SMALL_CCW_ARC_TO_NV, "arcTo-small-CCW", 5 },
{ GL_CLOSE_PATH_NV, "closePath", 0 } };
- for (size_t i = 0; i < sizeof(nameTab) / sizeof(nameTab[0]); ++i) {
- if (nameTab[i].cmd == cmd) {
+ for (const auto &nameTab : nameTabs) {
+ if (nameTab.cmd == cmd) {
QByteArray cs;
- for (int j = 0; j < nameTab[i].coordCount; ++j) {
+ for (int j = 0; j < nameTab.coordCount; ++j) {
cs.append(QByteArray::number(path.coord[ci++]));
cs.append(' ');
}
- debug << "\n " << nameTab[i].s << " " << cs;
+ debug << "\n " << nameTab.s << " " << cs;
break;
}
}