QMetaType::convert: Avoid some copies in ranged-for

Found by static analysis.

Change-Id: I416eb31736c8c5002fb4906aae4272e645f1916d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Fabian Kosmale 2023-03-21 15:41:48 +01:00
parent dc7f4f7b4e
commit b05540bd00

View File

@ -1258,26 +1258,26 @@ static const struct : QMetaTypeModuleHelper
QMETATYPE_CONVERTER(QByteArrayList, QVariantList,
result.reserve(source.size());
for (auto v: source)
for (const auto &v: source)
result.append(v.toByteArray());
return true;
);
QMETATYPE_CONVERTER(QVariantList, QByteArrayList,
result.reserve(source.size());
for (auto v: source)
for (const auto &v: source)
result.append(QVariant(v));
return true;
);
QMETATYPE_CONVERTER(QStringList, QVariantList,
result.reserve(source.size());
for (auto v: source)
for (const auto &v: source)
result.append(v.toString());
return true;
);
QMETATYPE_CONVERTER(QVariantList, QStringList,
result.reserve(source.size());
for (auto v: source)
for (const auto &v: source)
result.append(QVariant(v));
return true;
);