Ian
07/19/2020, 7:21 PMDominaezzz
07/19/2020, 8:10 PMIan
07/19/2020, 8:13 PMByteArray
will be serialized to raw bytes of the same length, or close to it?Paul Woitaschek
07/20/2020, 8:49 AMtravis
07/20/2020, 7:40 PMByteArray
is serialized as type 4 CBOR byte-by-byte (so seemingly sub-optimal, but I haven't benchmarked to confirm).
Not sure why that design choice, possibly because in the future they want to support serializing from an unknown length stream of data?
PR #898 adds CBOR type 2 serialization of ByteArray
and serializes the entire ByteArray
in a single pass (similar to how String
is serialized).travis
07/20/2020, 7:46 PMI guess I'm asking whether aCould've just been the data used, but in PR 898, it seems type 4 can sometimes take up more bytes than type 2. e.g.will be serialized to raw bytes of the same length, or close to it?ByteArray
0xCAFE
serialized to 0x383521
for type 4 (default type for kotlinx.serialization) and 0xCAFE
serialized to 0xCAFE
for type 2.
https://github.com/Kotlin/kotlinx.serialization/pull/898#discussion_r452625386