QString::insert: micro optimization

Don't call resize on QVLA, just wrap pointers in QSV
As drive-by, fix typo in comment

Change-Id: Id90236cfb53d861b8bd57fa9452aba4b8d9b20bf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Anton Kudryavtsev 2023-10-05 13:32:58 +03:00
parent 1219dbcd12
commit 05737f831c

View File

@ -3055,11 +3055,10 @@ QString &QString::insert(qsizetype i, QUtf8StringView s)
} else {
// Optimal insertion of Utf8 data is at the end, anywhere else could
// potentially lead to moving characters twice if Utf8 data size
// (variable-width) is less than the equiavalent Utf16 data size
// (variable-width) is less than the equivalent Utf16 data size
QVarLengthArray<char16_t> buffer(insert_size); // ### optimize (QTBUG-108546)
char16_t *b = QUtf8::convertToUnicode(buffer.data(), s);
buffer.resize(std::distance(buffer.begin(), b));
insert_helper(*this, i, buffer);
insert_helper(*this, i, QStringView(buffer.data(), b));
}
return *this;