Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
BoxyUwU committed Feb 3, 2023
1 parent e2f5eb5 commit af40cf2
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions crates/bevy_ecs/src/world/unsafe_world_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -818,24 +818,35 @@ unsafe fn get_ticks(
}

#[inline]
#[allow(unsafe_op_in_unsafe_fn)]
/// # Safety:
/// - the returned `Column` is only used in ways that the `world` has permission for.
/// - the returned `Column` is only used in ways that would not conflict with any existing
/// borrows of world data.
unsafe fn fetch_table(
world: UnsafeWorldCell<'_>,
location: EntityLocation,
component_id: ComponentId,
) -> Option<(&Column, TableRow)> {
let archetype = &world.archetypes()[location.archetype_id];
let table = &world.unsafe_world().storages.tables[archetype.table_id()];
// SAFETY: caller ensures returned data is not misused
let table = &unsafe { world.unsafe_world() }.storages.tables[archetype.table_id()];
let components = table.get_column(component_id)?;
let table_row = archetype.entity_table_row(location.archetype_row);
Some((components, table_row))
}

#[inline]
#[allow(unsafe_op_in_unsafe_fn)]
/// # Safety:
/// - the returned `ComponentSparseSet` is only used in ways that the `world` has permission for.
/// - the returned `ComponentSparseSet` is only used in ways that would not conflict with any existing
/// borrows of world data.
unsafe fn fetch_sparse_set(
world: UnsafeWorldCell<'_>,
component_id: ComponentId,
) -> Option<&ComponentSparseSet> {
world.unsafe_world().storages.sparse_sets.get(component_id)
// SAFETY: caller ensures returned data is not misused
unsafe { world.unsafe_world() }
.storages
.sparse_sets
.get(component_id)
}

0 comments on commit af40cf2

Please sign in to comment.