From cfc098253af9f6777df346aeb4b672fe998e5a2c Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sun, 21 May 2023 23:17:09 +0300 Subject: [PATCH] Moc: simplify the logic of a for-loop By handling the special case before entering the loop, then it can become a range-for, which fixes a narrowing conversion warning, and it becomes more readable. Change-Id: I6ce0181c95eae01a4f2bb7cd12fb5cbeba378586 Reviewed-by: Thiago Macieira Reviewed-by: Fabian Kosmale --- src/tools/moc/generator.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 9740f41255..128da4fd01 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -759,12 +759,12 @@ void Generator::generateFunctionParameters(const QList &list, const fprintf(out, " "); // Types - int argsCount = f.arguments.size(); - for (int j = -1; j < argsCount; ++j) { - if (j > -1) - fputc(' ', out); - const QByteArray &typeName = (j < 0) ? f.normalizedType : f.arguments.at(j).normalizedType; - generateTypeInfo(typeName, /*allowEmptyName=*/f.isConstructor); + const bool allowEmptyName = f.isConstructor; + generateTypeInfo(f.normalizedType, allowEmptyName); + fputc(',', out); + for (const ArgumentDef &arg : f.arguments) { + fputc(' ', out); + generateTypeInfo(arg.normalizedType, allowEmptyName); fputc(',', out); }