Fireboltofdeath / flamework-binary-serializer

A blazing fast binary serializer, or something
6 stars 0 forks source link

Add improved bitpacking #12

Closed Fireboltofdeath closed 3 months ago

Fireboltofdeath commented 3 months ago

BREAKING: DataType.Packed no longer supports intersections, and must be used like DataType.Packed<T>

The Packed type will now apply recursively to all types below it. This also lifts the restriction of packed types being limited to object types, and they can now be placed on any type (including tuples, booleans, etc)

Internally, the Packed type now allocates an array of booleans which can be arbitrarily sized or fixed size. In the case of arbitrarily sized boolean arrays, a byte will be allocated in the buffer indicating the length.

This array of booleans is always embedded at the start of the serialized buffer, which also means separately packed types will share the same space.

Optional fields now also optimize the presence boolean into a single bit.