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>
This commit is contained in:
Ahmad Samir 2023-05-21 23:17:09 +03:00
parent 0344332c76
commit cfc098253a

View File

@ -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)
const bool allowEmptyName = f.isConstructor;
generateTypeInfo(f.normalizedType, allowEmptyName);
fputc(',', out);
for (const ArgumentDef &arg : f.arguments) {
fputc(' ', out);
const QByteArray &typeName = (j < 0) ? f.normalizedType : f.arguments.at(j).normalizedType;
generateTypeInfo(typeName, /*allowEmptyName=*/f.isConstructor);
generateTypeInfo(arg.normalizedType, allowEmptyName);
fputc(',', out);
}