-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Unnecessary internal use of World::read_change_ticks #6812
Comments
Most places where I checked that were using e.g. /// Returns an [`Iterator`] over the query results for the given [`World`].
#[inline]
pub fn iter_mut<'w, 's>(&'s mut self, world: &'w mut World) -> QueryIter<'w, 's, Q, F> {
// SAFETY: query has unique world access
unsafe {
self.update_archetypes(world);
self.iter_unchecked_manual(world, world.last_change_tick(), world.change_tick()) // world is borrowed both as immutable and mutable here
}
} I did find two places where we can just replace the method but do you have any suggestions on these places where we can't? |
The change tick does not increment before those function calls, so it should still be correct to use |
Oh! I see, thanks for the clarification.😅 I can take care of this task @james7132. |
I'll push a PR that addresses this soon. One more question though @james7132: #[inline]
pub unsafe fn get_unchecked_mut<T: Component>(&self) -> Option<Mut<'_, T>> {
get_component_and_ticks_with_type(self.world, TypeId::of::<T>(), self.entity, self.location)
.map(|(value, ticks)| Mut {
value: value.assert_unique().deref_mut::<T>(),
ticks: Ticks::from_tick_cells(
ticks,
self.world.last_change_tick(),
self.world.read_change_tick(),
),
})
} In this case, |
…`bevy_ecs` crate (bevyengine#6816) # Objective - Fixes bevyengine#6812. ## Solution - Replaced `World::read_change_ticks` with `World::change_ticks` within `bevy_ecs` crate in places where `World` references were mutable. ---
…`bevy_ecs` crate (bevyengine#6816) # Objective - Fixes bevyengine#6812. ## Solution - Replaced `World::read_change_ticks` with `World::change_ticks` within `bevy_ecs` crate in places where `World` references were mutable. ---
…`bevy_ecs` crate (bevyengine#6816) # Objective - Fixes bevyengine#6812. ## Solution - Replaced `World::read_change_ticks` with `World::change_ticks` within `bevy_ecs` crate in places where `World` references were mutable. ---
We're currently using
World::read_change_ticks
in a variety of locations inbevy_ecs
where we have a&mut World
. This adds unnecessary atomic reads in locations where we can use normal loads. These usages can be replaced withWorld::change_tick
instead.The text was updated successfully, but these errors were encountered: