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

Use 16-bit lengths on 16-bit targets #234

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kornelski
Copy link
Contributor

@kornelski kornelski commented Jan 26, 2023

This changes the internal length type from u32 to u16 on 16-bit targets. On 16-bit targets larger arrays won't be used, 32-bit arithmetic can be expensive, and 4 bytes is a significant overhead.

target_pointer_width is not going to be smaller than "16", so #[cfg(not(target_pointer_width = "16"))] is sufficient to mean > 16.

Rustup doesn't ship a 16-bit target by default, so unfortunately it's not easy to add a compile test for it, but the tests pass with u16 LenUint on larger platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant