diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2023-05-21 23:17:09 +0300 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2023-06-22 02:20:29 +0300 |
commit | cfc098253af9f6777df346aeb4b672fe998e5a2c (patch) | |
tree | 436ba30d17df415c15216ccc94ffadba8cfbd515 | |
parent | 0344332c769db98920c821652c6a6b3fa2502f72 (diff) |
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 <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r-- | src/tools/moc/generator.cpp | 12 |
1 files 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<FunctionDef> &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); } |