Pitch: An opt-in warning for avoidable struct padding
Swift Forums
Pitch: An opt-in warning for avoidable struct padding
Swift lays out stored properties in declaration order and never reorders them, so a poorly ordered struct silently wastes memory bandwidth. This pitch proposes an off-by-default diagnostic group that warns when reordering a type's stored properties would shrink its stride, with intentional layouts opted out per type through @diagnose and a written reason. Motivation The same three fields take 24 instead of 16 bytes per element (50 % more) when the large field is not first, and a bandwidth-bound...
Swift lays out stored properties in declaration order and never reorders them, so a poorly ordered struct silently wastes memory bandwidth. This pitch proposes an off-by-default…
0 comments
No comments yet.