-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
What do you think about serializing numeric types with the smallest lossless format? For example, if I have a double[] of length N containing 0's and 1's, its contents (after the header) would be stored using N bytes, because 0 and 1 fit losslessly into a positive fixnum. If I try to then deserialize to a double[], that would work.
msgpack-cli is already doing this for ints and uints internally.
The implementation of DoubleMsgPackValue.Pack would become something logically similar to this:
public override void Pack(Packer packer)
{
if (this.Value == (int)this.Value)
{
packer.Pack(this.Value < 0 ? (int)this.Value : (uint)this.Value);
}
else if (this.Value == (float)this.Value)
{
packer.Pack((float)this.Value);
}
else
{
packer.Pack(this.Value);
}
}
What are your thoughts? This could potentially be an optional configuration on the MessagePackWriter. I'd be willing to help out with this.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels