hf-api includes a function that computes a CRC32 of a chunk of data. Unfortunately, it made the (easy, common) mistake of allocating a crc::Crc on the stack.
The upstream crc crate, despite our protests, optimizes for time over space. A crc::Crc includes a lookup table to accelerate the calculation of the CRC. Creating one at runtime on the stack means
The lookup table is on your stack (all 2048 bytes of it, in this case), and
Your function now contains code to generate the lookup table.
This is a footgun in the crc API design, IMO. It's far too easy to make this mistake.
Anyway, made it static for a 2 kiB improvement in stack margin.
hf-api includes a function that computes a CRC32 of a chunk of data. Unfortunately, it made the (easy, common) mistake of allocating a crc::Crc on the stack.
The upstream crc crate, despite our protests, optimizes for time over space. A crc::Crc includes a lookup table to accelerate the calculation of the CRC. Creating one at runtime on the stack means
The lookup table is on your stack (all 2048 bytes of it, in this case), and
Your function now contains code to generate the lookup table.
This is a footgun in the crc API design, IMO. It's far too easy to make this mistake.
Anyway, made it static for a 2 kiB improvement in stack margin.