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

nonzero! macro is not (yet) zero cost #20

Open
rukai opened this issue Mar 18, 2022 · 1 comment
Open

nonzero! macro is not (yet) zero cost #20

rukai opened this issue Mar 18, 2022 · 1 comment

Comments

@rukai
Copy link

rukai commented Mar 18, 2022

Looking at the output of cargo asm on my application I can see function calls being generated from the nonzero macro
image

We could possibly add an #[inline(always)] but I dont think that will necessarily be enough, there might be more logic included.
To ensure it is actually zero cost we will need to make the macro generate code within a const context via rust-lang/rust#76001 once that is stabilized.

@antifuchs
Copy link
Owner

...oh noooo. Thanks for finding this & bringing it up!

Inlining sounds reasonable. Don't think we can do a const block in any case, because it needs to call a trait method, so until those can be const, I think inlining will be the best we can do. /:

I'd be happy to merge a PR & roll a release with this.

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

2 participants