3 ms·
Wow! Do you have numbers anywhere showing the space saved? Especially for step 6, using a Vec as a Box, I would not expect that to save much.
by 01HNNWZ0MV43FF 3y ago
Wow! Do you have numbers anywhere showing the space saved? Especially for step 6, using a Vec as a Box, I would not expect that to save much.
- __s 3y agoUnfortunately nothing concrete, it's a few kb here & there. I'd estimate I've saved ~300kb overall. I'd have to go back to compare these things. Removing floats saved more space than I expected Also important is configuring compiler correctly, [profile.release] opt-level = "z" lto = "fat" codegen-units = 1
- pdpi 3y ago> Especially for step 6, using a Vec as a Box, I would not expect that to save much. It's not that using a Vec as a Box saves anything at all. It's that generics require monomorphisation, and that eats up a bunch of space, and more instances of generic types translates into more space. If your application uses Vec<i16> elsewhere, you've already paid the binary size price for using it. Vec<i16> is close enough to Box<[i16]> that the functional differences don't warrant the extra code generation.
- nextaccountic 3y agohe meant Box<[T]> (aka fixed-size vec or heap allocated array) rather than Box<T> (a single heap allocated element)