inkeliz / karmem

Karmem is a fast binary serialization format, faster than Google Flatbuffers and optimized for TinyGo and WASM.
BSD 3-Clause "New" or "Revised" License
654 stars 27 forks source link

kmgen,kmparser,benchmark: add packed() document and struct tag #76

Closed inkeliz closed 2 years ago

inkeliz commented 2 years ago

Now, it's possible (and recommended) to use @packed() to produce smaller encoded data. Additionally, table will use @packed() by default, and that is backward-compatible.

That change also removes the size-each value from slice-headers, which saves 4-bytes per each dynamic array.

This tag can be use in the project header, enabling it on all inline struct declared in the file:

karmem name @packed();

This tag can be used to enable/disable @packed() for each inline:

struct Foo inline @packed(true) { ... }

If the document is using @packed(true), it's possible to opt-out, using @packed(false) for specific struct:

struct Foo inline @packed(false) { ... }

There's no reason to use @packed(false), except from compatibility reasons, for projects releases before this patch.

Closes #71 Closes #65 Fixes #32

Signed-off-by: Inkeliz inkeliz@inkeliz.com