Skip to content

Conversation

turalcar
Copy link

Don't use boxes: Not only this avoids allocation but also makes no_std implementation possible.
I didn't bother to rewrite the comment (it's not like I entirely understand how it works anyway). but there are 2 main issues to consider:

  1. Alignment: union Blank has both the max size and max alignment of its arguments
  2. Niches: for some implementation-defined reason this combination of Options and Result works. We likely use the fact that union have no niches.

Together with removing black_box and inline(never) this achieves performance identical with std on my ARMv8.

Don't use boxes: Not only this avoids allocation but also makes no_std
implementation possible.
I didn't bother to rewrite the comment (it's not like I entirely
understand how it works anyway). but there are 2 main issues to
consider:
1) Alignment: union Blank has both the max size and max alignment of its
   arguments
2) Niches: for some implementation-defined reason this combination of
   Options and Result works. We likely use the fact that union have no
   niches.

Together with removing black_box and inline(never) this achieves
performance identical with std on my ARMv8.
Copy link

@CyanChanges CyanChanges left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good

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.

2 participants