gregjesl/brutezone

Attribute Packing

Closed this issue · 0 comments

From @huelsenfruchtzwerg's pull request (#17)

The offset for Africa/Monrovia before 1972 12:44:30 AM UTC is actually incorrect right now because it's stored as a 44 minutes, but correct would be 44:30 minutes. This could be addressed by storing the offset in seconds. Due to alignment, this shouldn't actually change the actual size of the generated table, at least on platforms where _Alignof(time_t) == sizeof(time_t). Testing around with the available platforms on godbolt, this appear to be most of them (x86, x86-64, arm, arm64, and from my own testing xtensa/esp32 as well), except AVR/Arduino unfortunately.

On the other hand, if we keep the offsets in minutes as a short (and live with Monrovia being incorrect or find another fix) we could use attribute((packed)) on timezone_offset to save a few byte per offset for a slight cpu-time cost, which adds up to quite a bit of size-savings (tested on my x86-64 machine, on 32bit platforms the savings would end up lower but still quite substantial).