Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize API type layouts and add size tests #113

Open
xFrednet opened this issue Feb 12, 2023 · 0 comments
Open

Optimize API type layouts and add size tests #113

xFrednet opened this issue Feb 12, 2023 · 0 comments
Labels
A-api Area: Stable API C-enhancement Category: New feature or request E-good-first-issue Participation: Good for newcomers

Comments

@xFrednet
Copy link
Member

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

@xFrednet xFrednet added C-enhancement Category: New feature or request E-good-first-issue Participation: Good for newcomers A-api Area: Stable API labels Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-api Area: Stable API C-enhancement Category: New feature or request E-good-first-issue Participation: Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant