Optimize API type layouts and add size tests #113
Labels
A-api
Area: Stable API
C-enhancement
Category: New feature or request
E-good-first-issue
Participation: Good for newcomers
API types use
[repr(C)]
to allow transfer over FFI boundaries. This forces the structs to have a layout as declared in code, plus additional padding for alignment. While creating the API, I always just created the structs, without considering the order and size of the types. As a result, they can probably be optimized.Additionally, I'd like some tests, to validate that the size doesn't unintentionally changes. Rustc does something similar here:
https://github.com/rust-lang/rust/blob/51cb5614dde163c53aab73e2dc33bb9f388b50a8/compiler/rustc_hir/src/hir.rs#L3959-L3994
The text was updated successfully, but these errors were encountered: