Skip to content

Commit

Permalink
Remove outdated uses of single-tuple bundles (#6406)
Browse files Browse the repository at this point in the history
# Objective

Bevy still has many instances of using single-tuples `(T,)` to create a bundle. Due to #2975, this is no longer necessary.

## Solution

Search for regex `\(.+\s*,\)`. This should have found every instance.
  • Loading branch information
JoJoJet committed Oct 29, 2022
1 parent dfb80ee commit 336049d
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion benches/benches/bevy_ecs/components/add_remove.rs
Expand Up @@ -12,7 +12,7 @@ impl Benchmark {
let mut world = World::default();

let entities = world
.spawn_batch((0..10000).map(|_| (A(0.0),)))
.spawn_batch((0..10000).map(|_| A(0.0)))
.collect::<Vec<_>>();

Self(world, entities)
Expand Down
8 changes: 4 additions & 4 deletions benches/benches/bevy_ecs/world/world_get.rs
Expand Up @@ -31,7 +31,7 @@ fn deterministic_rand() -> ChaCha8Rng {

fn setup<T: Component + Default>(entity_count: u32) -> World {
let mut world = World::default();
world.spawn_batch((0..entity_count).map(|_| (T::default(),)));
world.spawn_batch((0..entity_count).map(|_| T::default()));
black_box(world)
}

Expand Down Expand Up @@ -308,7 +308,7 @@ pub fn query_get_component(criterion: &mut Criterion) {
group.bench_function(format!("{}_entities_table", entity_count), |bencher| {
let mut world = World::default();
let mut entities: Vec<_> = world
.spawn_batch((0..entity_count).map(|_| (Table::default(),)))
.spawn_batch((0..entity_count).map(|_| Table::default()))
.collect();
entities.shuffle(&mut deterministic_rand());
let mut query = SystemState::<Query<&Table>>::new(&mut world);
Expand All @@ -330,7 +330,7 @@ pub fn query_get_component(criterion: &mut Criterion) {
group.bench_function(format!("{}_entities_sparse", entity_count), |bencher| {
let mut world = World::default();
let mut entities: Vec<_> = world
.spawn_batch((0..entity_count).map(|_| (Sparse::default(),)))
.spawn_batch((0..entity_count).map(|_| Sparse::default()))
.collect();
entities.shuffle(&mut deterministic_rand());
let mut query = SystemState::<Query<&Sparse>>::new(&mut world);
Expand Down Expand Up @@ -363,7 +363,7 @@ pub fn query_get(criterion: &mut Criterion) {
group.bench_function(format!("{}_entities_table", entity_count), |bencher| {
let mut world = World::default();
let mut entities: Vec<_> = world
.spawn_batch((0..entity_count).map(|_| (Table::default(),)))
.spawn_batch((0..entity_count).map(|_| Table::default()))
.collect();
entities.shuffle(&mut deterministic_rand());
let mut query = SystemState::<Query<&Table>>::new(&mut world);
Expand Down
14 changes: 7 additions & 7 deletions crates/bevy_ecs/src/query/mod.rs
Expand Up @@ -97,8 +97,8 @@ mod tests {

let mut world = World::new();
world.spawn((A(1), B(1)));
world.spawn((A(2),));
world.spawn((A(3),));
world.spawn(A(2));
world.spawn(A(3));

assert_all_sizes_equal::<&A, With<B>>(&mut world, 1);
assert_all_sizes_equal::<&A, Without<B>>(&mut world, 2);
Expand All @@ -110,10 +110,10 @@ mod tests {
world.spawn((A(4), C(4)));
world.spawn((A(5), C(5)));
world.spawn((A(6), C(6)));
world.spawn((A(7),));
world.spawn((A(8),));
world.spawn((A(9),));
world.spawn((A(10),));
world.spawn(A(7));
world.spawn(A(8));
world.spawn(A(9));
world.spawn(A(10));

// With/Without for B and C
assert_all_sizes_equal::<&A, With<B>>(&mut world, 3);
Expand Down Expand Up @@ -444,7 +444,7 @@ mod tests {
fn query_iter_combinations_sparse() {
let mut world = World::new();

world.spawn_batch((1..=4).map(|i| (Sparse(i),)));
world.spawn_batch((1..=4).map(Sparse));

let mut query = world.query::<&mut Sparse>();
let mut combinations = query.iter_combinations_mut(&mut world);
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_hierarchy/src/child_builder.rs
Expand Up @@ -632,7 +632,7 @@ mod tests {
fn push_and_insert_and_remove_children_commands() {
let mut world = World::default();
let entities = world
.spawn_batch(vec![(C(1),), (C(2),), (C(3),), (C(4),), (C(5),)])
.spawn_batch(vec![C(1), C(2), C(3), C(4), C(5)])
.collect::<Vec<Entity>>();

let mut queue = CommandQueue::default();
Expand Down Expand Up @@ -693,7 +693,7 @@ mod tests {
fn push_and_insert_and_remove_children_world() {
let mut world = World::default();
let entities = world
.spawn_batch(vec![(C(1),), (C(2),), (C(3),), (C(4),), (C(5),)])
.spawn_batch(vec![C(1), C(2), C(3), C(4), C(5)])
.collect::<Vec<Entity>>();

world.entity_mut(entities[0]).push_children(&entities[1..3]);
Expand Down Expand Up @@ -737,7 +737,7 @@ mod tests {
fn children_removed_when_empty_world() {
let mut world = World::default();
let entities = world
.spawn_batch(vec![(C(1),), (C(2),), (C(3),)])
.spawn_batch(vec![C(1), C(2), C(3)])
.collect::<Vec<Entity>>();

let parent1 = entities[0];
Expand Down Expand Up @@ -769,7 +769,7 @@ mod tests {
fn children_removed_when_empty_commands() {
let mut world = World::default();
let entities = world
.spawn_batch(vec![(C(1),), (C(2),), (C(3),)])
.spawn_batch(vec![C(1), C(2), C(3)])
.collect::<Vec<Entity>>();

let parent1 = entities[0];
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/render/mesh.rs
Expand Up @@ -239,7 +239,7 @@ pub fn extract_skinned_meshes(
SkinnedMeshJoints::build(skin, &inverse_bindposes, &joint_query, &mut joints)
{
last_start = last_start.max(skinned_joints.index as usize);
values.push((entity, (skinned_joints.to_buffer_index(),)));
values.push((entity, skinned_joints.to_buffer_index()));
}
}

Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_render/src/extract_component.rs
Expand Up @@ -115,10 +115,10 @@ fn prepare_uniform_components<C: Component>(
.map(|(entity, component)| {
(
entity,
(DynamicUniformIndex::<C> {
DynamicUniformIndex::<C> {
index: component_uniforms.uniforms.push(component.clone()),
marker: PhantomData,
},),
},
)
})
.collect::<Vec<_>>();
Expand Down Expand Up @@ -187,7 +187,7 @@ fn extract_components<C: ExtractComponent>(
) {
let mut values = Vec::with_capacity(*previous_len);
for (entity, query_item) in &query {
values.push((entity, (C::extract_component(query_item),)));
values.push((entity, C::extract_component(query_item)));
}
*previous_len = values.len();
commands.insert_or_spawn_batch(values);
Expand All @@ -202,7 +202,7 @@ fn extract_visible_components<C: ExtractComponent>(
let mut values = Vec::with_capacity(*previous_len);
for (entity, computed_visibility, query_item) in &query {
if computed_visibility.is_visible() {
values.push((entity, (C::extract_component(query_item),)));
values.push((entity, C::extract_component(query_item)));
}
}
*previous_len = values.len();
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_sprite/src/render/mod.rs
Expand Up @@ -555,7 +555,7 @@ pub fn queue_sprites(
{
current_batch = new_batch;
current_image_size = Vec2::new(gpu_image.size.x, gpu_image.size.y);
current_batch_entity = commands.spawn((current_batch,)).id();
current_batch_entity = commands.spawn(current_batch).id();

image_bind_groups
.values
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ui/src/render/mod.rs
Expand Up @@ -425,11 +425,11 @@ pub fn prepare_uinodes(
for extracted_uinode in &extracted_uinodes.uinodes {
if current_batch_handle != extracted_uinode.image {
if start != end {
commands.spawn((UiBatch {
commands.spawn(UiBatch {
range: start..end,
image: current_batch_handle,
z: last_z,
},));
});
start = end;
}
current_batch_handle = extracted_uinode.image.clone_weak();
Expand Down
2 changes: 1 addition & 1 deletion examples/2d/mesh2d_manual.rs
Expand Up @@ -300,7 +300,7 @@ pub fn extract_colored_mesh2d(
if !computed_visibility.is_visible() {
continue;
}
values.push((entity, (ColoredMesh2d,)));
values.push((entity, ColoredMesh2d));
}
*previous_len = values.len();
commands.insert_or_spawn_batch(values);
Expand Down

0 comments on commit 336049d

Please sign in to comment.