Rename num_entities to entity_count (#19781)

As discussed in
https://github.com/bevyengine/bevy/pull/19780#issuecomment-2994554024.
This commit is contained in:
mgi388 2025-06-23 15:08:02 +10:00 committed by GitHub
parent 0518eda2ad
commit efd17f133d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 11 additions and 11 deletions

View File

@ -1582,7 +1582,7 @@ mod tests {
app.add_systems(EnterMainMenu, (foo, bar));
app.world_mut().run_schedule(EnterMainMenu);
assert_eq!(app.world().num_entities(), 2);
assert_eq!(app.world().entity_count(), 2);
}
#[test]

View File

@ -1637,7 +1637,7 @@ mod tests {
assert_eq!(q1.iter(&world).len(), 1);
assert_eq!(q2.iter(&world).len(), 1);
assert_eq!(world.num_entities(), 2);
assert_eq!(world.entity_count(), 2);
world.clear_entities();
@ -1652,7 +1652,7 @@ mod tests {
"world should not contain sparse set components"
);
assert_eq!(
world.num_entities(),
world.entity_count(),
0,
"world should not have any entities"
);

View File

@ -727,7 +727,7 @@ mod tests {
world.spawn(A).flush();
assert_eq!(vec!["add_2", "add_1"], world.resource::<Order>().0);
// Our A entity plus our two observers
assert_eq!(world.num_entities(), 3);
assert_eq!(world.entity_count(), 3);
}
#[test]

View File

@ -2342,7 +2342,7 @@ mod tests {
.spawn((W(1u32), W(2u64)))
.id();
command_queue.apply(&mut world);
assert_eq!(world.num_entities(), 1);
assert_eq!(world.entity_count(), 1);
let results = world
.query::<(&W<u32>, &W<u64>)>()
.iter(&world)

View File

@ -423,12 +423,12 @@ mod test {
let mut world = World::new();
queue.apply(&mut world);
assert_eq!(world.num_entities(), 2);
assert_eq!(world.entity_count(), 2);
// The previous call to `apply` cleared the queue.
// This call should do nothing.
queue.apply(&mut world);
assert_eq!(world.num_entities(), 2);
assert_eq!(world.entity_count(), 2);
}
#[expect(
@ -462,7 +462,7 @@ mod test {
queue.push(SpawnCommand);
queue.push(SpawnCommand);
queue.apply(&mut world);
assert_eq!(world.num_entities(), 3);
assert_eq!(world.entity_count(), 3);
}
#[test]

View File

@ -220,7 +220,7 @@ impl World {
///
/// This is helpful as a diagnostic, but it can also be used effectively in tests.
#[inline]
pub fn num_entities(&self) -> u32 {
pub fn entity_count(&self) -> u32 {
self.entities.len()
}

View File

@ -535,12 +535,12 @@ pub fn extract_clusters(
continue;
}
let num_entities: usize = clusters
let entity_count: usize = clusters
.clusterable_objects
.iter()
.map(|l| l.entities.len())
.sum();
let mut data = Vec::with_capacity(clusters.clusterable_objects.len() + num_entities);
let mut data = Vec::with_capacity(clusters.clusterable_objects.len() + entity_count);
for cluster_objects in &clusters.clusterable_objects {
data.push(ExtractedClusterableObjectElement::ClusterHeader(
cluster_objects.counts,