Reuse the serializedList variable in serializeListType

We may reuse the variable instead of instantiating the empty
QByteArray.

Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: I4c0b92926af6904f5003f3511f6dcf0e89c1e42f
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
This commit is contained in:
Alexey Edelev 2024-10-01 23:40:17 +02:00
parent dcaf650f2f
commit d575f3e07b
1 changed files with 3 additions and 3 deletions

View File

@ -226,10 +226,10 @@ template <typename V, if_length_delimited<V> = true>
template <typename V, if_not_length_delimited<V> = true>
[[nodiscard]] QByteArray serializeListType(const QList<V> &listValue)
{
if (listValue.isEmpty())
return {};
QByteArray serializedList;
if (listValue.isEmpty())
return serializedList;
for (auto &value : listValue)
serializedList.append(serializeBasic<V>(value));