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

# Objective

- The tick access methods mention "ticks" (as in: plural). Yet, most of
them only access a single tick.

## Solution

- Rename those methods and fix docs to reflect the singular aspect of
the return values

---

## Migration Guide

The following method names were renamed, from `foo_ticks_bar` to
`foo_tick_bar` (`ticks` is now singular, `tick`):
- `ComponentSparseSet::get_added_ticks` → `get_added_tick`
- `ComponentSparseSet::get_changed_ticks` → `get_changed_tick`
- `Column::get_added_ticks` → `get_added_tick`
- `Column::get_changed_ticks` → `get_changed_tick`
- `Column::get_added_ticks_unchecked` → `get_added_tick_unchecked`
- `Column::get_changed_ticks_unchecked` → `get_changed_tick_unchecked`
This commit is contained in:
Nicola Papale 2023-09-11 21:25:06 +02:00 committed by GitHub
parent 4fe2b1220d
commit 19c53578e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 20 deletions

View File

@ -574,7 +574,7 @@ impl_tick_filter!(
Added, Added,
AddedFetch, AddedFetch,
Column::get_added_ticks_slice, Column::get_added_ticks_slice,
ComponentSparseSet::get_added_ticks ComponentSparseSet::get_added_tick
); );
impl_tick_filter!( impl_tick_filter!(
@ -612,7 +612,7 @@ impl_tick_filter!(
Changed, Changed,
ChangedFetch, ChangedFetch,
Column::get_changed_ticks_slice, 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. /// A marker trait to indicate that the filter works at an archetype level.

View File

@ -161,10 +161,10 @@ impl<const SEND: bool> ResourceData<SEND> {
if self.is_present() { if self.is_present() {
self.validate_access(); self.validate_access();
self.column.replace_untracked(Self::ROW, value); 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 *self
.column .column
.get_changed_ticks_unchecked(Self::ROW) .get_changed_tick_unchecked(Self::ROW)
.deref_mut() = change_ticks.changed; .deref_mut() = change_ticks.changed;
} else { } else {
if !SEND { if !SEND {

View File

@ -231,8 +231,8 @@ impl ComponentSparseSet {
Some(( Some((
self.dense.get_data_unchecked(dense_index), self.dense.get_data_unchecked(dense_index),
TickCells { TickCells {
added: self.dense.get_added_ticks_unchecked(dense_index), added: self.dense.get_added_tick_unchecked(dense_index),
changed: self.dense.get_changed_ticks_unchecked(dense_index), changed: self.dense.get_changed_tick_unchecked(dense_index),
}, },
)) ))
} }
@ -242,7 +242,7 @@ impl ComponentSparseSet {
/// ///
/// Returns `None` if `entity` does not have a component in the sparse set. /// Returns `None` if `entity` does not have a component in the sparse set.
#[inline] #[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; let dense_index = *self.sparse.get(entity.index())? as usize;
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
assert_eq!(entity, self.entities[dense_index]); assert_eq!(entity, self.entities[dense_index]);
@ -250,7 +250,7 @@ impl ComponentSparseSet {
unsafe { unsafe {
Some( Some(
self.dense self.dense
.get_added_ticks_unchecked(TableRow::new(dense_index)), .get_added_tick_unchecked(TableRow::new(dense_index)),
) )
} }
} }
@ -259,7 +259,7 @@ impl ComponentSparseSet {
/// ///
/// Returns `None` if `entity` does not have a component in the sparse set. /// Returns `None` if `entity` does not have a component in the sparse set.
#[inline] #[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; let dense_index = *self.sparse.get(entity.index())? as usize;
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
assert_eq!(entity, self.entities[dense_index]); assert_eq!(entity, self.entities[dense_index]);
@ -267,7 +267,7 @@ impl ComponentSparseSet {
unsafe { unsafe {
Some( Some(
self.dense self.dense
.get_changed_ticks_unchecked(TableRow::new(dense_index)), .get_changed_tick_unchecked(TableRow::new(dense_index)),
) )
} }
} }

View File

@ -404,7 +404,7 @@ impl Column {
self.data.get_unchecked_mut(row.index()) 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. /// Returns `None` if `row` is out of bounds.
/// ///
@ -414,11 +414,11 @@ impl Column {
/// ///
/// [`UnsafeCell`]: std::cell::UnsafeCell /// [`UnsafeCell`]: std::cell::UnsafeCell
#[inline] #[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()) 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. /// Returns `None` if `row` is out of bounds.
/// ///
@ -428,7 +428,7 @@ impl Column {
/// ///
/// [`UnsafeCell`]: std::cell::UnsafeCell /// [`UnsafeCell`]: std::cell::UnsafeCell
#[inline] #[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()) self.changed_ticks.get(row.index())
} }
@ -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. /// this function does not do any bounds checking.
/// ///
/// # Safety /// # Safety
/// `row` must be within the range `[0, self.len())`. /// `row` must be within the range `[0, self.len())`.
#[inline] #[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()); debug_assert!(row.index() < self.added_ticks.len());
self.added_ticks.get_unchecked(row.index()) 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. /// this function does not do any bounds checking.
/// ///
/// # Safety /// # Safety
/// `row` must be within the range `[0, self.len())`. /// `row` must be within the range `[0, self.len())`.
#[inline] #[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()); debug_assert!(row.index() < self.changed_ticks.len());
self.changed_ticks.get_unchecked(row.index()) self.changed_ticks.get_unchecked(row.index())
} }

View File

@ -953,8 +953,8 @@ unsafe fn get_component_and_ticks(
Some(( Some((
components.get_data_unchecked(location.table_row), components.get_data_unchecked(location.table_row),
TickCells { TickCells {
added: components.get_added_ticks_unchecked(location.table_row), added: components.get_added_tick_unchecked(location.table_row),
changed: components.get_changed_ticks_unchecked(location.table_row), changed: components.get_changed_tick_unchecked(location.table_row),
}, },
)) ))
} }