Skip to content
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

Fix naming on "tick" Column and ComponentSparseSet methods #9744

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/query/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ impl_tick_filter!(
Added,
AddedFetch,
Column::get_added_ticks_slice,
ComponentSparseSet::get_added_ticks
ComponentSparseSet::get_added_tick
);

impl_tick_filter!(
Expand Down Expand Up @@ -612,7 +612,7 @@ impl_tick_filter!(
Changed,
ChangedFetch,
Column::get_changed_ticks_slice,
ComponentSparseSet::get_changed_ticks
ComponentSparseSet::get_changed_tick
);

/// A marker trait to indicate that the filter works at an archetype level.
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/storage/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ impl<const SEND: bool> ResourceData<SEND> {
if self.is_present() {
self.validate_access();
self.column.replace_untracked(Self::ROW, value);
*self.column.get_added_ticks_unchecked(Self::ROW).deref_mut() = change_ticks.added;
*self.column.get_added_tick_unchecked(Self::ROW).deref_mut() = change_ticks.added;
*self
.column
.get_changed_ticks_unchecked(Self::ROW)
.get_changed_tick_unchecked(Self::ROW)
.deref_mut() = change_ticks.changed;
} else {
if !SEND {
Expand Down
12 changes: 6 additions & 6 deletions crates/bevy_ecs/src/storage/sparse_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ impl ComponentSparseSet {
Some((
self.dense.get_data_unchecked(dense_index),
TickCells {
added: self.dense.get_added_ticks_unchecked(dense_index),
changed: self.dense.get_changed_ticks_unchecked(dense_index),
added: self.dense.get_added_tick_unchecked(dense_index),
changed: self.dense.get_changed_tick_unchecked(dense_index),
},
))
}
Expand All @@ -242,15 +242,15 @@ impl ComponentSparseSet {
///
/// Returns `None` if `entity` does not have a component in the sparse set.
#[inline]
pub fn get_added_ticks(&self, entity: Entity) -> Option<&UnsafeCell<Tick>> {
pub fn get_added_tick(&self, entity: Entity) -> Option<&UnsafeCell<Tick>> {
let dense_index = *self.sparse.get(entity.index())? as usize;
#[cfg(debug_assertions)]
assert_eq!(entity, self.entities[dense_index]);
// SAFETY: if the sparse index points to something in the dense vec, it exists
unsafe {
Some(
self.dense
.get_added_ticks_unchecked(TableRow::new(dense_index)),
.get_added_tick_unchecked(TableRow::new(dense_index)),
)
}
}
Expand All @@ -259,15 +259,15 @@ impl ComponentSparseSet {
///
/// Returns `None` if `entity` does not have a component in the sparse set.
#[inline]
pub fn get_changed_ticks(&self, entity: Entity) -> Option<&UnsafeCell<Tick>> {
pub fn get_changed_tick(&self, entity: Entity) -> Option<&UnsafeCell<Tick>> {
let dense_index = *self.sparse.get(entity.index())? as usize;
#[cfg(debug_assertions)]
assert_eq!(entity, self.entities[dense_index]);
// SAFETY: if the sparse index points to something in the dense vec, it exists
unsafe {
Some(
self.dense
.get_changed_ticks_unchecked(TableRow::new(dense_index)),
.get_changed_tick_unchecked(TableRow::new(dense_index)),
)
}
}
Expand Down
16 changes: 8 additions & 8 deletions crates/bevy_ecs/src/storage/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ impl Column {
self.data.get_unchecked_mut(row.index())
}

/// Fetches the "added" change detection ticks for the value at `row`.
/// Fetches the "added" change detection tick for the value at `row`.
///
/// Returns `None` if `row` is out of bounds.
///
Expand All @@ -414,11 +414,11 @@ impl Column {
///
/// [`UnsafeCell`]: std::cell::UnsafeCell
#[inline]
pub fn get_added_ticks(&self, row: TableRow) -> Option<&UnsafeCell<Tick>> {
pub fn get_added_tick(&self, row: TableRow) -> Option<&UnsafeCell<Tick>> {
self.added_ticks.get(row.index())
}

/// Fetches the "changed" change detection ticks for the value at `row`.
/// Fetches the "changed" change detection tick for the value at `row`.
///
/// Returns `None` if `row` is out of bounds.
///
Expand All @@ -428,7 +428,7 @@ impl Column {
///
/// [`UnsafeCell`]: std::cell::UnsafeCell
#[inline]
pub fn get_changed_ticks(&self, row: TableRow) -> Option<&UnsafeCell<Tick>> {
pub fn get_changed_tick(&self, row: TableRow) -> Option<&UnsafeCell<Tick>> {
self.changed_ticks.get(row.index())
}

Expand All @@ -445,24 +445,24 @@ impl Column {
}
}

/// Fetches the "added" change detection ticks for the value at `row`. Unlike [`Column::get_added_ticks`]
/// Fetches the "added" change detection tick for the value at `row`. Unlike [`Column::get_added_tick`]
/// this function does not do any bounds checking.
///
/// # Safety
/// `row` must be within the range `[0, self.len())`.
#[inline]
pub unsafe fn get_added_ticks_unchecked(&self, row: TableRow) -> &UnsafeCell<Tick> {
pub unsafe fn get_added_tick_unchecked(&self, row: TableRow) -> &UnsafeCell<Tick> {
debug_assert!(row.index() < self.added_ticks.len());
self.added_ticks.get_unchecked(row.index())
}

/// Fetches the "changed" change detection ticks for the value at `row`. Unlike [`Column::get_changed_ticks`]
/// Fetches the "changed" change detection tick for the value at `row`. Unlike [`Column::get_changed_tick`]
/// this function does not do any bounds checking.
///
/// # Safety
/// `row` must be within the range `[0, self.len())`.
#[inline]
pub unsafe fn get_changed_ticks_unchecked(&self, row: TableRow) -> &UnsafeCell<Tick> {
pub unsafe fn get_changed_tick_unchecked(&self, row: TableRow) -> &UnsafeCell<Tick> {
debug_assert!(row.index() < self.changed_ticks.len());
self.changed_ticks.get_unchecked(row.index())
}
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/world/unsafe_world_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -953,8 +953,8 @@ unsafe fn get_component_and_ticks(
Some((
components.get_data_unchecked(location.table_row),
TickCells {
added: components.get_added_ticks_unchecked(location.table_row),
changed: components.get_changed_ticks_unchecked(location.table_row),
added: components.get_added_tick_unchecked(location.table_row),
changed: components.get_changed_tick_unchecked(location.table_row),
},
))
}
Expand Down