mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Fix double indirection when applying command queues (#11822)
# Objective When applying a command, we currently use double indirection for the world reference `&mut Option<&mut World>`. Since this is used across a `fn` pointer boundary, this can't get optimized away. ## Solution Reborrow the world reference and pass `Option<&mut World>` instead.
This commit is contained in:
parent
eee71bfa93
commit
bd25135330
1 changed files with 2 additions and 2 deletions
|
@ -14,7 +14,7 @@ struct CommandMeta {
|
|||
///
|
||||
/// Returns the size of `T` in bytes.
|
||||
consume_command_and_get_size:
|
||||
unsafe fn(value: OwningPtr<Unaligned>, world: &mut Option<&mut World>) -> usize,
|
||||
unsafe fn(value: OwningPtr<Unaligned>, world: Option<&mut World>) -> usize,
|
||||
}
|
||||
|
||||
/// Densely and efficiently stores a queue of heterogenous types implementing [`Command`].
|
||||
|
@ -157,7 +157,7 @@ impl CommandQueue {
|
|||
// SAFETY: The data underneath the cursor must correspond to the type erased in metadata,
|
||||
// since they were stored next to each other by `.push()`.
|
||||
// For ZSTs, the type doesn't matter as long as the pointer is non-null.
|
||||
let size = unsafe { (meta.consume_command_and_get_size)(cmd, &mut world) };
|
||||
let size = unsafe { (meta.consume_command_and_get_size)(cmd, world.as_deref_mut()) };
|
||||
// Advance the cursor past the command. For ZSTs, the cursor will not move.
|
||||
// At this point, it will either point to the next `CommandMeta`,
|
||||
// or the cursor will be out of bounds and the loop will end.
|
||||
|
|
Loading…
Reference in a new issue