QList: use new assign() in operator=(std::initializer_list)

operator=(~) and assign(~) share similar names but, until now, have not
shared the same functionality. This patch introduces the usage of
QList::assign() within the non-sharing assignment operator to
effectively boost efficiency by reusing the available capacity.

Task-number: QTBUG-106201
Change-Id: I01a0511af336f2f410158a07d91e5759c8ff46db
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Dennis Oberst 2023-08-09 15:54:36 +02:00
parent 3db9ef358d
commit 09e698d826
1 changed files with 1 additions and 4 deletions

View File

@ -289,10 +289,7 @@ public:
QList<T> &operator=(std::initializer_list<T> args)
{
d = DataPointer(Data::allocate(qsizetype(args.size())));
if (args.size())
d->copyAppend(args.begin(), args.end());
return *this;
return assign(args);
}
template <typename InputIterator, if_input_iterator<InputIterator> = true>