Skip to content

Commit cd69b55

Browse files
move fetch_table and fetch_sparse_set to World
1 parent a71bdda commit cd69b55

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
@@ -1586,7 +1586,7 @@ impl World {
15861586
) -> Option<(Ptr<'_>, TickCells<'_>)> {
15871587
match storage_type {
15881588
StorageType::Table => {
1589-
let (components, table_row) = fetch_table(self, location, component_id)?;
1589+
let (components, table_row) = self.fetch_table(location, component_id)?;
15901590

15911591
// SAFETY: archetypes only store valid table_rows and caller ensure aliasing rules
15921592
Some((
@@ -1597,7 +1597,7 @@ impl World {
15971597
},
15981598
))
15991599
}
1600-
StorageType::SparseSet => fetch_sparse_set(self, component_id)?.get_with_ticks(entity),
1600+
StorageType::SparseSet => self.fetch_sparse_set(component_id)?.get_with_ticks(entity),
16011601
}
16021602
}
16031603

@@ -1640,11 +1640,11 @@ impl World {
16401640
// SAFETY: component_id exists and is therefore valid
16411641
match storage_type {
16421642
StorageType::Table => {
1643-
let (components, table_row) = fetch_table(self, location, component_id)?;
1643+
let (components, table_row) = self.fetch_table(location, component_id)?;
16441644
// SAFETY: archetypes only store valid table_rows and caller ensure aliasing rules
16451645
Some(components.get_data_unchecked(table_row))
16461646
}
1647-
StorageType::SparseSet => fetch_sparse_set(self, component_id)?.get(entity),
1647+
StorageType::SparseSet => self.fetch_sparse_set(component_id)?.get(entity),
16481648
}
16491649
}
16501650

@@ -1686,31 +1686,31 @@ impl World {
16861686
) -> Option<ComponentTicks> {
16871687
match storage_type {
16881688
StorageType::Table => {
1689-
let (components, table_row) = fetch_table(self, location, component_id)?;
1689+
let (components, table_row) = self.fetch_table(location, component_id)?;
16901690
// SAFETY: archetypes only store valid table_rows and caller ensure aliasing rules
16911691
Some(components.get_ticks_unchecked(table_row))
16921692
}
1693-
StorageType::SparseSet => fetch_sparse_set(self, component_id)?.get_ticks(entity),
1693+
StorageType::SparseSet => self.fetch_sparse_set(component_id)?.get_ticks(entity),
16941694
}
16951695
}
1696-
}
16971696

1698-
#[inline]
1699-
unsafe fn fetch_table(
1700-
world: &World,
1701-
location: EntityLocation,
1702-
component_id: ComponentId,
1703-
) -> Option<(&Column, TableRow)> {
1704-
let archetype = &world.archetypes[location.archetype_id];
1705-
let table = &world.storages.tables[archetype.table_id()];
1706-
let components = table.get_column(component_id)?;
1707-
let table_row = archetype.entity_table_row(location.archetype_row);
1708-
Some((components, table_row))
1709-
}
1697+
#[inline]
1698+
unsafe fn fetch_table(
1699+
&self,
1700+
location: EntityLocation,
1701+
component_id: ComponentId,
1702+
) -> Option<(&Column, TableRow)> {
1703+
let archetype = &self.archetypes[location.archetype_id];
1704+
let table = &self.storages.tables[archetype.table_id()];
1705+
let components = table.get_column(component_id)?;
1706+
let table_row = archetype.entity_table_row(location.archetype_row);
1707+
Some((components, table_row))
1708+
}
17101709

1711-
#[inline]
1712-
fn fetch_sparse_set(world: &World, component_id: ComponentId) -> Option<&ComponentSparseSet> {
1713-
world.storages.sparse_sets.get(component_id)
1710+
#[inline]
1711+
fn fetch_sparse_set(&self, component_id: ComponentId) -> Option<&ComponentSparseSet> {
1712+
self.storages.sparse_sets.get(component_id)
1713+
}
17141714
}
17151715

17161716
impl fmt::Debug for World {

0 commit comments

Comments
 (0)