[Interest] Smaller QString Serialization
Thiago Macieira
thiago.macieira at intel.com
Tue Apr 15 16:02:15 CEST 2025
On Tuesday, 15 April 2025 01:32:56 Pacific Daylight Time Ivan Solovev via
Interest wrote:
> > My primary question is: is there a way to avoid doing a copy for the utf8
> > data (the char *buffer in operator>> and the QByteArray utf8 in
> > operator<<)?
>
> QString stores the data as UTF-16, so you won't be able to avoid a copy
> if you want to convert the data to/from UTF-8.
>
> I didn't have a look at the implementation, but one thing to note is that
> IIUC defining your own serialization operators for QString would be
> an ODR violation. So, maybe you'd need to wrap QString into a custom
> struct first.
Or just not use QDataStream in the first place.
Using CBOR, strings are serialised as UTF-8 with a compressed size. Null-vs-
empty distinction is lost, though.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Principal Engineer - Intel DCAI Platform & System Engineering
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5150 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20250415/2ab149e9/attachment.bin>
More information about the Interest
mailing list