-
Notifications
You must be signed in to change notification settings - Fork 143
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
Remove unsafety in ResourceId
creation
#534
Conversation
Oh wait we increment after.. the comment just irritated me. |
I'd actually be okay to merge this after removing the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a safety comment to the dangerous initialization spot. If we later add code inbetween the variable initialization and the unsafe block, then it's easier to miss that it is crucial that it is initialized as 1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather just match Xilem exactly, i.e. use .try_into().unwrap()
. This is our only usage of unsafe
, which it would be nice to remove.
- We're nowhere near CPU bottlenecked;
- this will be called very few times a frame (~15?); and,
- it is only a single comparison which should be branch predicted well
Also, that title is probably too long. If you apply this suggestion, I'd change it to:
Remove unsafety in
ResourceId
allocation
Yeah best to keep PR titles at 64 chars or below, otherwise it will be elided in the commit list on the GitHub web interface. |
ResourceId
creation
I'm not 100% for removing unsafe "just because it's the only one for now" and it's still safe and safes performance and binary size in theory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! In this case, the unsafe code was safe for all reasonable scenarios, but it's still good to not get in the habit of using it (and it was technically unsound).
Co-authored-by: Daniel McNab <[email protected]>
@DasLixou I sent you a GitHub invite for getting write access to this repo. We have a policy of PR author pressing the merge button. Once you accept the invite you can press it here. The reason behind this policy is that sometimes the PR author may want to wait for multiple reviews, or for a review from a specific person. Or they may want to do some final polish. Sometimes when the PR is very trivial, e.g. just a single typo fix, then it's fine for a reviewer to just merge it. |
Accepted the invitation, still for some PRs like #516 I just like to have as much reviews and opinions as possible. Also, when I get inactive or something you can just kick me. But is this an indirect call to merge this? |
It got an approval, so yes? |
Yes you can merge this. 🙂 |
Make atomic
ID_COUNTER
increment matchxilem
style and clear confusion with safety comment