Array of bits #17
-
Hello. This packs quite well:
Can this be packed better?
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
The packing algo works for Objects to get the smallest possible size, an Array packing algo can also be added to help but you can also simulate it for now. For example an Object with 7 3-bit fields comes out to 3 bytes total, vs the 8 bytes in your example array: const schema = { // packs to 3 bytes
0: bits(3),
1: bits(3),
2: bits(3),
3: bits(3),
4: bits(3),
5: bits(3),
6: bits(3),
}; An Array packing algo would automate this for you, this was planned to be added but did not do yet |
Beta Was this translation helpful? Give feedback.
-
Thanks for giving me some ideas. What is the best way to pack something like this?
The number of bits is known, but the array length is dynamic, like:
|
Beta Was this translation helpful? Give feedback.
-
Master branch now has Array packing, |
Beta Was this translation helpful? Give feedback.
Master branch now has Array packing,
array(bits(x))
will give the smallest possible size #18 Also object packing got more efficient for certain cases