Skip to content

Commit

Permalink
use world_metadata instead of unsafe_world
Browse files Browse the repository at this point in the history
  • Loading branch information
BoxyUwU committed Feb 6, 2023
1 parent 76e77f6 commit 609f38e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions crates/bevy_ecs/src/world/unsafe_world_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,39 +156,39 @@ impl<'w> UnsafeWorldCell<'w> {
pub fn entities(self) -> &'w Entities {
// SAFETY:
// - we only access world metadata
&unsafe { self.unsafe_world() }.entities
&unsafe { self.world_metadata() }.entities
}

/// Retrieves this world's [Archetypes] collection
#[inline]
pub fn archetypes(self) -> &'w Archetypes {
// SAFETY:
// - we only access world metadata
&unsafe { self.unsafe_world() }.archetypes
&unsafe { self.world_metadata() }.archetypes
}

/// Retrieves this world's [Components] collection
#[inline]
pub fn components(self) -> &'w Components {
// SAFETY:
// - we only access world metadata
&unsafe { self.unsafe_world() }.components
&unsafe { self.world_metadata() }.components
}

/// Retrieves this world's [Bundles] collection
#[inline]
pub fn bundles(self) -> &'w Bundles {
// SAFETY:
// - we only access world metadata
&unsafe { self.unsafe_world() }.bundles
&unsafe { self.world_metadata() }.bundles
}

/// Reads the current change tick of this world.
#[inline]
pub fn read_change_tick(self) -> u32 {
// SAFETY:
// - we only access world metadata
unsafe { self.unsafe_world() }
unsafe { self.world_metadata() }
.change_tick
.load(Ordering::Acquire)
}
Expand All @@ -197,14 +197,14 @@ impl<'w> UnsafeWorldCell<'w> {
pub fn last_change_tick(self) -> u32 {
// SAFETY:
// - we only access world metadata
unsafe { self.unsafe_world() }.last_change_tick
unsafe { self.world_metadata() }.last_change_tick
}

#[inline]
pub fn increment_change_tick(self) -> u32 {
// SAFETY:
// - we only access world metadata
unsafe { self.unsafe_world() }
unsafe { self.world_metadata() }
.change_tick
.fetch_add(1, Ordering::AcqRel)
}
Expand All @@ -217,7 +217,7 @@ impl<'w> UnsafeWorldCell<'w> {
) -> Option<ArchetypeComponentId> {
// SAFETY:
// - we only access world metadata
let resource = unsafe { self.unsafe_world() }
let resource = unsafe { self.world_metadata() }
.storages
.resources
.get(component_id)?;
Expand All @@ -232,7 +232,7 @@ impl<'w> UnsafeWorldCell<'w> {
) -> Option<ArchetypeComponentId> {
// SAFETY:
// - we only access world metadata
let resource = unsafe { self.unsafe_world() }
let resource = unsafe { self.world_metadata() }
.storages
.non_send_resources
.get(component_id)?;
Expand Down

0 comments on commit 609f38e

Please sign in to comment.