From b05540bd00d051c74e67d138f5148eb23e018996 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Tue, 21 Mar 2023 15:41:48 +0100 Subject: [PATCH] QMetaType::convert: Avoid some copies in ranged-for Found by static analysis. Change-Id: I416eb31736c8c5002fb4906aae4272e645f1916d Reviewed-by: Qt CI Bot Reviewed-by: Thiago Macieira --- src/corelib/kernel/qmetatype.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index b476451ed0..481d409deb 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -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; );