QStringConverter: allow appendToBuffer() to write to the buffer

Even if we later decide that the data we wrote was incomplete. This
allows us to use the buffer as a scratch area, improving performance. I
need this for a faster SIMD encoding, because it stores a tentative
conversion to US-ASCII before searching where the last valid conversion
was. I was getting:

   Actual   (buffer)    : "\x00""dcdcdcd"
   Expected ("cdcdcdcd"): cdcdcdcd

Amends the tests added by f1c0bd2e06 for
finalize().

[ChangeLog][Important Behavior Change] The appendToBuffer() functions
in QStringEncoder and QStringDecoder may write to parts of the
provided output beyond the returned pointer. Caller code must not
assume the data beyond that remains unmodified.

Pick-to: 6.8
Change-Id: If59c4017cac9ee82ca45fffd29cceb9832ae98e5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 23ec36d1b2)
(cherry picked from commit 95a267d867)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Thiago Macieira 2025-08-15 15:39:25 -07:00 committed by Qt Cherry-pick Bot
parent 6400e30481
commit 4ae32f5bdd
1 changed files with 5 additions and 2 deletions

View File

@ -2765,7 +2765,8 @@ const char *QStringConverter::nameForEncoding(QStringConverter::Encoding e) noex
\note \a out must be large enough to be able to hold all the decoded data. Use
requiredSpace() to determine the maximum size requirement to be able to encode
\a in.
\a in. This function may write to any bytes between \a out and \c{out +
requiredSpace()}, including those past the returned end pointer.
\sa requiredSpace()
*/
@ -2861,7 +2862,9 @@ const char *QStringConverter::nameForEncoding(QStringConverter::Encoding e) noex
\a out needs to be large enough to be able to hold all the decoded data. Use
\l{requiredSpace} to determine the maximum size requirements to decode an encoded
data buffer of \c in.size() bytes.
data buffer of \c in.size() bytes. This function may write to any bytes
between \a out and \c{out + requiredSpace()}, including those past the
returned end pointer.
\sa requiredSpace
*/