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

Make BundleInfo's fields not pub(crate) #8068

Merged
merged 2 commits into from
Mar 13, 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
6 changes: 3 additions & 3 deletions crates/bevy_ecs/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,13 @@ impl SparseSetIndex for BundleId {
}

pub struct BundleInfo {
pub(crate) id: BundleId,
pub(crate) component_ids: Vec<ComponentId>,
id: BundleId,
component_ids: Vec<ComponentId>,
}

impl BundleInfo {
#[inline]
pub fn id(&self) -> BundleId {
pub const fn id(&self) -> BundleId {
self.id
}

Expand Down
18 changes: 10 additions & 8 deletions crates/bevy_ecs/src/world/entity_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ impl<'w> EntityMut<'w> {
return None;
}

let mut bundle_components = bundle_info.component_ids.iter().cloned();
let mut bundle_components = bundle_info.components().iter().cloned();
let entity = self.entity;
// SAFETY: bundle components are iterated in order, which guarantees that the component type
// matches
Expand Down Expand Up @@ -463,7 +463,7 @@ impl<'w> EntityMut<'w> {

let old_archetype = &mut archetypes[old_location.archetype_id];
let entity = self.entity;
for component_id in bundle_info.component_ids.iter().cloned() {
for component_id in bundle_info.components().iter().cloned() {
if old_archetype.contains(component_id) {
removed_components.send(component_id, entity);

Expand Down Expand Up @@ -694,9 +694,11 @@ unsafe fn remove_bundle_from_archetype(
let remove_bundle_result = {
let current_archetype = &mut archetypes[archetype_id];
if intersection {
current_archetype.edges().get_remove_bundle(bundle_info.id)
current_archetype
.edges()
.get_remove_bundle(bundle_info.id())
} else {
current_archetype.edges().get_take_bundle(bundle_info.id)
current_archetype.edges().get_take_bundle(bundle_info.id())
}
};
let result = if let Some(result) = remove_bundle_result {
Expand All @@ -710,7 +712,7 @@ unsafe fn remove_bundle_from_archetype(
let current_archetype = &mut archetypes[archetype_id];
let mut removed_table_components = Vec::new();
let mut removed_sparse_set_components = Vec::new();
for component_id in bundle_info.component_ids.iter().cloned() {
for component_id in bundle_info.components().iter().cloned() {
if current_archetype.contains(component_id) {
// SAFETY: bundle components were already initialized by bundles.get_info
let component_info = components.get_info_unchecked(component_id);
Expand All @@ -724,7 +726,7 @@ unsafe fn remove_bundle_from_archetype(
// graph
current_archetype
.edges_mut()
.insert_take_bundle(bundle_info.id, None);
.insert_take_bundle(bundle_info.id(), None);
return None;
}
}
Expand Down Expand Up @@ -763,11 +765,11 @@ unsafe fn remove_bundle_from_archetype(
if intersection {
current_archetype
.edges_mut()
.insert_remove_bundle(bundle_info.id, result);
.insert_remove_bundle(bundle_info.id(), result);
} else {
current_archetype
.edges_mut()
.insert_take_bundle(bundle_info.id, result);
.insert_take_bundle(bundle_info.id(), result);
}
result
}
Expand Down