From cd800da526aaf0369f9cf4780db065026ddad7dd Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 11 Feb 2023 20:50:20 -0800 Subject: [PATCH] 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 --- src/corelib/text/qstring.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index ab76aadd1dd..b88511087ac 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -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(unicode, unicode + size)); + QVarLengthArray copy(unicode, unicode + size); + insert(i, copy.data(), size); } else { insert_helper(*this, i, QStringView(unicode, size)); }