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 the representation of NotNaN #114

Open
notgull opened this issue Oct 24, 2022 · 2 comments
Open

Optimize the representation of NotNaN #114

notgull opened this issue Oct 24, 2022 · 2 comments

Comments

@notgull
Copy link
Contributor

notgull commented Oct 24, 2022

Here's a thought experiment which would almost certainly be a breaking change, but something worth looking into nonetheless.

Right now, the inner representation of a NotNan<T> is a T. However, we know one thing about the value: it will never (soundly) be a NaN. Using this information, we could optimize the inner representation of the type so that Option<NotNan<T>> is a no-op. This could be done by using wrapping addition and subtraction combined with NonZeroU32/NonZeroU64. What are your thoughts on this?

@mbrubeck
Copy link
Collaborator

rust-lang/rfcs#3334 would be the ideal way to allow this optimization, if it is eventually accepted and stabilized.

@soooch
Copy link

soooch commented Feb 15, 2023

fyi rust-lang/rfcs#3334 was closed in favor of rust-lang/rust#103724 which in turn was closed in favor of rust-lang/rust#107606

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

No branches or pull requests

3 participants