Three changes that bring the size of DateTime<Tz> down from 48 bytes to 20 bytes:
The build script collects all abbreviations and concatenates them into one string. We compactly store an index and length into this string in one i16. All abbreviations are at most 6 characters and the entire string is ca. 650 characters. So it fits easily.
The base offset from UTC doesn't fit into an i16, it needs 17 bits. We give it 18 bits of an i32. The DST offset from the base offset is much smaller, it can fit into the remaining 14 bits. This spares one i32.
There are 2 bytes of padding in the FixedTimespan type, and 2 bytes of padding in the TzOffset type. If we don't wrap the FixedTimespan but copy its two fields into TzOffset we get rid of the padding, which is 33% of the type.
A binary compiled with these size optimizations is 1,5Mb smaller :tada:.
Three changes that bring the size of
DateTime<Tz>
down from 48 bytes to 20 bytes:i16
. All abbreviations are at most 6 characters and the entire string is ca. 650 characters. So it fits easily.i16
, it needs 17 bits. We give it 18 bits of ani32
. The DST offset from the base offset is much smaller, it can fit into the remaining 14 bits. This spares onei32
.FixedTimespan
type, and 2 bytes of padding in theTzOffset
type. If we don't wrap theFixedTimespan
but copy its two fields intoTzOffset
we get rid of the padding, which is 33% of the type.A binary compiled with these size optimizations is 1,5Mb smaller :tada:.
Fixes https://github.com/chronotope/chrono-tz/issues/27.