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:
parent
1219dbcd12
commit
05737f831c
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user