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:
parent
b9394b48c1
commit
cd800da526
@ -3086,7 +3086,8 @@ QString& QString::insert(qsizetype i, const QChar *unicode, qsizetype size)
|
|||||||
|
|
||||||
// In case when data points into "this"
|
// In case when data points into "this"
|
||||||
if (!d->needsDetach() && QtPrivate::q_points_into_range(unicode, *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 {
|
} else {
|
||||||
insert_helper(*this, i, QStringView(unicode, size));
|
insert_helper(*this, i, QStringView(unicode, size));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user