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

[Merged by Bors] - Constify SpritePipelineKey implementation. #6976

Closed
wants to merge 3 commits into from
Closed

[Merged by Bors] - Constify SpritePipelineKey implementation. #6976

wants to merge 3 commits into from

Conversation

AxiomaticSemantics
Copy link
Contributor

Objective

  • Describe the objective or issue this PR addresses.
    SpritePipelineKey could use more constification.

Solution

Constify SpritePipelineKey implementation.

Changelog

@james7132 james7132 added A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Dec 19, 2022
@james7132 james7132 added this to the 0.10 milestone Dec 19, 2022
Self::from_bits(msaa_bits).unwrap()
// SAFETY: The input is the correct type and the mask will ensure the output range is
// capped
unsafe { Self::from_bits_unchecked(msaa_bits) }
Copy link
Contributor

Choose a reason for hiding this comment

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

For other reviewers here's the safety comment from the bitflags crate

https://docs.rs/bitflags/latest/src/bitflags/lib.rs.html#575-577

/// The caller of `from_bits_unchecked()` has to ensure that
/// all bits correspond to a defined flag or that extra bits
/// are valid for this bitflags type.

Copy link
Contributor

@hymm hymm left a comment

Choose a reason for hiding this comment

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

Could we add some docs for these functions? Not going to block on that though.

@james7132 james7132 added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Dec 19, 2022
Self::from_bits(msaa_bits).unwrap()
// SAFETY: The input is the correct type and the mask will ensure the output range is
// capped
unsafe { Self::from_bits_unchecked(msaa_bits) }
Copy link
Member

@cart cart Dec 20, 2022

Choose a reason for hiding this comment

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

Idk if this is a good enough reason to introduce unsafe code. Does const-ing this unlock specific scenarios we need? Are there performance benefits (that we have measured)?

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
unsafe { Self::from_bits_unchecked(msaa_bits) }
Self::from_bits_truncate(msaa_bits)

This should be const and safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I overlooked that, will fix it shortly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@james7132 james7132 requested a review from cart December 23, 2022 20:53
@alice-i-cecile
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request Dec 25, 2022
# Objective

- Describe the objective or issue this PR addresses.
SpritePipelineKey could use more constification.

## Solution
Constify SpritePipelineKey implementation.

## Changelog


Co-authored-by: AxiomaticSemantics <117950168+AxiomaticSemantics@users.noreply.github.com>
@bors
Copy link
Contributor

bors bot commented Dec 25, 2022

Build failed (retrying...):

bors bot pushed a commit that referenced this pull request Dec 25, 2022
# Objective

- Describe the objective or issue this PR addresses.
SpritePipelineKey could use more constification.

## Solution
Constify SpritePipelineKey implementation.

## Changelog


Co-authored-by: AxiomaticSemantics <117950168+AxiomaticSemantics@users.noreply.github.com>
@bors bors bot changed the title Constify SpritePipelineKey implementation. [Merged by Bors] - Constify SpritePipelineKey implementation. Dec 25, 2022
@bors bors bot closed this Dec 25, 2022
@AxiomaticSemantics AxiomaticSemantics deleted the constify branch December 25, 2022 01:49
alradish pushed a commit to alradish/bevy that referenced this pull request Jan 22, 2023
# Objective

- Describe the objective or issue this PR addresses.
SpritePipelineKey could use more constification.

## Solution
Constify SpritePipelineKey implementation.

## Changelog


Co-authored-by: AxiomaticSemantics <117950168+AxiomaticSemantics@users.noreply.github.com>
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
# Objective

- Describe the objective or issue this PR addresses.
SpritePipelineKey could use more constification.

## Solution
Constify SpritePipelineKey implementation.

## Changelog


Co-authored-by: AxiomaticSemantics <117950168+AxiomaticSemantics@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants