QString::insert: replace duplicated code with a recursion

Just call itself after copying the buffer, thus avoiding instantiating
insert_helper() for QVarLengthArray.

The other two cases of QtPrivate::q_points_into_range + QVLA in
qstring.cpp are not worth changing.

Change-Id: I9671dee8ceb64aa9b9cafffd1742fa7bb4cbebd8
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
Thiago Macieira 2023-02-11 20:50:20 -08:00 committed by Marc Mutz
parent b9394b48c1
commit cd800da526

View File

@ -3086,7 +3086,8 @@ QString& QString::insert(qsizetype i, const QChar *unicode, qsizetype size)
// In case when data points into "this"
if (!d->needsDetach() && QtPrivate::q_points_into_range(unicode, *this)) {
insert_helper(*this, i, QVarLengthArray<QChar>(unicode, unicode + size));
QVarLengthArray copy(unicode, unicode + size);
insert(i, copy.data(), size);
} else {
insert_helper(*this, i, QStringView(unicode, size));
}