Skip to content

Commit 0c483cf

Browse files
move fetch_table and fetch_sparse_set to World
1 parent 8f5733e commit 0c483cf

File tree

1 file changed

+22
-22
lines changed
  • crates/bevy_ecs/src/world

1 file changed

+22
-22
lines changed

crates/bevy_ecs/src/world/mod.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,7 +1800,7 @@ impl World {
18001800
) -> Option<(Ptr<'_>, TickCells<'_>)> {
18011801
match storage_type {
18021802
StorageType::Table => {
1803-
let (components, table_row) = fetch_table(self, location, component_id)?;
1803+
let (components, table_row) = self.fetch_table(location, component_id)?;
18041804

18051805
// SAFETY: archetypes only store valid table_rows and caller ensure aliasing rules
18061806
Some((
@@ -1811,7 +1811,7 @@ impl World {
18111811
},
18121812
))
18131813
}
1814-
StorageType::SparseSet => fetch_sparse_set(self, component_id)?.get_with_ticks(entity),
1814+
StorageType::SparseSet => self.fetch_sparse_set(component_id)?.get_with_ticks(entity),
18151815
}
18161816
}
18171817

@@ -1854,11 +1854,11 @@ impl World {
18541854
// SAFETY: component_id exists and is therefore valid
18551855
match storage_type {
18561856
StorageType::Table => {
1857-
let (components, table_row) = fetch_table(self, location, component_id)?;
1857+
let (components, table_row) = self.fetch_table(location, component_id)?;
18581858
// SAFETY: archetypes only store valid table_rows and caller ensure aliasing rules
18591859
Some(components.get_data_unchecked(table_row))
18601860
}
1861-
StorageType::SparseSet => fetch_sparse_set(self, component_id)?.get(entity),
1861+
StorageType::SparseSet => self.fetch_sparse_set(component_id)?.get(entity),
18621862
}
18631863
}
18641864

@@ -1900,31 +1900,31 @@ impl World {
19001900
) -> Option<ComponentTicks> {
19011901
match storage_type {
19021902
StorageType::Table => {
1903-
let (components, table_row) = fetch_table(self, location, component_id)?;
1903+
let (components, table_row) = self.fetch_table(location, component_id)?;
19041904
// SAFETY: archetypes only store valid table_rows and caller ensure aliasing rules
19051905
Some(components.get_ticks_unchecked(table_row))
19061906
}
1907-
StorageType::SparseSet => fetch_sparse_set(self, component_id)?.get_ticks(entity),
1907+
StorageType::SparseSet => self.fetch_sparse_set(component_id)?.get_ticks(entity),
19081908
}
19091909
}
1910-
}
19111910

1912-
#[inline]
1913-
unsafe fn fetch_table(
1914-
world: &World,
1915-
location: EntityLocation,
1916-
component_id: ComponentId,
1917-
) -> Option<(&Column, TableRow)> {
1918-
let archetype = &world.archetypes[location.archetype_id];
1919-
let table = &world.storages.tables[archetype.table_id()];
1920-
let components = table.get_column(component_id)?;
1921-
let table_row = archetype.entity_table_row(location.archetype_row);
1922-
Some((components, table_row))
1923-
}
1911+
#[inline]
1912+
unsafe fn fetch_table(
1913+
&self,
1914+
location: EntityLocation,
1915+
component_id: ComponentId,
1916+
) -> Option<(&Column, TableRow)> {
1917+
let archetype = &self.archetypes[location.archetype_id];
1918+
let table = &self.storages.tables[archetype.table_id()];
1919+
let components = table.get_column(component_id)?;
1920+
let table_row = archetype.entity_table_row(location.archetype_row);
1921+
Some((components, table_row))
1922+
}
19241923

1925-
#[inline]
1926-
fn fetch_sparse_set(world: &World, component_id: ComponentId) -> Option<&ComponentSparseSet> {
1927-
world.storages.sparse_sets.get(component_id)
1924+
#[inline]
1925+
fn fetch_sparse_set(&self, component_id: ComponentId) -> Option<&ComponentSparseSet> {
1926+
self.storages.sparse_sets.get(component_id)
1927+
}
19281928
}
19291929

19301930
impl fmt::Debug for World {

0 commit comments

Comments
 (0)