Optimize QXmlStreamWriterPrivate::doWriteToDevice(QLatin1StringView)
Use a stack buffer, and perform the recoding from L1 to U8 in chunks. Solves the L1 case of Task-number: QTBUG-109284 Pick-to: 6.5 Change-Id: Ia9ac7d8b27fd452d24d9e27f0575f9fc83b6dcbc Reviewed-by: Mate Barany <mate.barany@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
2ae75c2e6a
commit
e3f230e7be
@ -3085,10 +3085,14 @@ void QXmlStreamWriterPrivate::doWriteToDevice(QUtf8StringView s)
|
|||||||
|
|
||||||
void QXmlStreamWriterPrivate::doWriteToDevice(QLatin1StringView s)
|
void QXmlStreamWriterPrivate::doWriteToDevice(QLatin1StringView s)
|
||||||
{
|
{
|
||||||
QByteArray utf8(s.size() * 2, Qt::Uninitialized);
|
constexpr qsizetype MaxChunkSize = 512;
|
||||||
char *end = QUtf8::convertFromLatin1(utf8.data(), s);
|
char buffer [2 * MaxChunkSize];
|
||||||
utf8.truncate(end - utf8.data());
|
while (!s.isEmpty()) {
|
||||||
doWriteToDevice(QUtf8StringView{utf8});
|
const qsizetype chunkSize = std::min(s.size(), MaxChunkSize);
|
||||||
|
char *end = QUtf8::convertFromLatin1(buffer, s.first(chunkSize));
|
||||||
|
doWriteToDevice(QUtf8StringView{buffer, end});
|
||||||
|
s = s.sliced(chunkSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user