-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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] - small ecs cleanup and remove_bundle drop bugfix #2172
Conversation
Frizi
commented
May 15, 2021
- simplified code around archetype generations a little bit, as the special case value is not actually needed
- removed unnecessary UnsafeCell around pointer value that is never updated through shared references
- fixed and added a test for correct drop behaviour when removing sparse components through remove_bundle command
This looks good to me. Love the archetype generation simplification! I added UnsafeCell largely because hecs does it in a similar context. We never create shared mutable references to a particular "range" in As long as these use cases are ok, I'm down to remove it. But I want to be doubly sure before removing it (and im not even singly sure at this point 😄). |
|
I buy that. I think that means that hecs could remove it too? @Ralith you might want to look in to this? |
Thanks for the ping! My knee-jerk reaction is that the interpretation implied by this change makes more sense; the argument for |
Co-authored-by: Nathan Ward <43621845+NathanSWard@users.noreply.github.com>
Every source I've checked confirms that |
data: UnsafeCell<NonNull<u8>>, | ||
swap_scratch: UnsafeCell<NonNull<u8>>, | ||
data: NonNull<u8>, | ||
swap_scratch: NonNull<u8>, |
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 can confirm this UnsafeCell
is unnecessary. Neither pointer is itself changed behind &self
. Only the pointed to value can be changed using &self
, which is fine as they are raw pointers that are not derived from a reference.
Sounds like we have consensus. A big thanks to everyone for providing insight! |
bors r+ |
- simplified code around archetype generations a little bit, as the special case value is not actually needed - removed unnecessary UnsafeCell around pointer value that is never updated through shared references - fixed and added a test for correct drop behaviour when removing sparse components through remove_bundle command
Pull request successfully merged into main. Build succeeded: |
The shared memory is behind a raw pointer, which reference visibility semantics don't see through. See bevyengine/bevy#2172 for discussion.
The shared memory is behind a raw pointer, which reference visibility semantics don't see through. See bevyengine/bevy#2172 for discussion.
The shared memory is behind a raw pointer, which reference visibility semantics don't see through. See bevyengine/bevy#2172 for discussion.
The shared memory is behind a raw pointer, which reference visibility semantics don't see through. See bevyengine/bevy#2172 for discussion.
- simplified code around archetype generations a little bit, as the special case value is not actually needed - removed unnecessary UnsafeCell around pointer value that is never updated through shared references - fixed and added a test for correct drop behaviour when removing sparse components through remove_bundle command