SomeRandomiOSDev / CBORCoding

Easy CBOR encoding and decoding for iOS, macOS, tvOS and watchOS.
MIT License
51 stars 14 forks source link

String table #15

Closed joskuijpers closed 3 years ago

joskuijpers commented 4 years ago

Hi,

I have used this package to encode (essentially) a lis of 500 structs that have the same keys. It seems that in the binary encoding, the keys are now repeated 500 times, taking up up to 50% of the total encoding size.

Is this according to spec? Have there been considerations to have a string table?

I have not looked too deeply into the CBOR details. If it is truly like json, and you can simply embed one CBOR object into another CBOR object, then I guess a header is not possible.

Does anyone know how to build a string table with Codable? Then I can add it to a fork.

joskuijpers commented 4 years ago

I ran the output of this package through a compression algorithm and it seems to compress really well. So this is not a priority or even needed for me. My 80kb file went to 7kb with lzmse and 5kb with lzma.

SomeRandomiOSDev commented 3 years ago

According to the CBOR specification this is how the keys have to be encoded. It sounds like the compression solution is probably better than deviating from the spec