From 1dfb159859daf161c38d31aa0c0469f98ad07ade Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Sat, 29 Oct 2022 12:22:20 -0400 Subject: [PATCH 1/3] Remove single-tuple bundles --- benches/benches/bevy_ecs/components/add_remove.rs | 2 +- benches/benches/bevy_ecs/world/world_get.rs | 8 ++++---- crates/bevy_ecs/src/query/mod.rs | 14 +++++++------- crates/bevy_hierarchy/src/child_builder.rs | 8 ++++---- crates/bevy_pbr/src/render/mesh.rs | 2 +- crates/bevy_render/src/extract_component.rs | 4 ++-- examples/2d/mesh2d_manual.rs | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/benches/benches/bevy_ecs/components/add_remove.rs b/benches/benches/bevy_ecs/components/add_remove.rs index 0c5bc56b45b8e..a41f8ed9538f4 100644 --- a/benches/benches/bevy_ecs/components/add_remove.rs +++ b/benches/benches/bevy_ecs/components/add_remove.rs @@ -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::>(); Self(world, entities) diff --git a/benches/benches/bevy_ecs/world/world_get.rs b/benches/benches/bevy_ecs/world/world_get.rs index 1feb7ca07a3eb..2a4e7337fb276 100644 --- a/benches/benches/bevy_ecs/world/world_get.rs +++ b/benches/benches/bevy_ecs/world/world_get.rs @@ -31,7 +31,7 @@ fn deterministic_rand() -> ChaCha8Rng { fn setup(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) } @@ -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::>::new(&mut world); @@ -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::>::new(&mut world); @@ -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::>::new(&mut world); diff --git a/crates/bevy_ecs/src/query/mod.rs b/crates/bevy_ecs/src/query/mod.rs index dff4b9a251f41..f84c12339db65 100644 --- a/crates/bevy_ecs/src/query/mod.rs +++ b/crates/bevy_ecs/src/query/mod.rs @@ -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>(&mut world, 1); assert_all_sizes_equal::<&A, Without>(&mut world, 2); @@ -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>(&mut world, 3); @@ -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(|i| Sparse(i))); let mut query = world.query::<&mut Sparse>(); let mut combinations = query.iter_combinations_mut(&mut world); diff --git a/crates/bevy_hierarchy/src/child_builder.rs b/crates/bevy_hierarchy/src/child_builder.rs index 652bdf766e678..721e3c06b1ef2 100644 --- a/crates/bevy_hierarchy/src/child_builder.rs +++ b/crates/bevy_hierarchy/src/child_builder.rs @@ -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::>(); let mut queue = CommandQueue::default(); @@ -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::>(); world.entity_mut(entities[0]).push_children(&entities[1..3]); @@ -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::>(); let parent1 = entities[0]; @@ -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::>(); let parent1 = entities[0]; diff --git a/crates/bevy_pbr/src/render/mesh.rs b/crates/bevy_pbr/src/render/mesh.rs index 0862ff5248e5d..b89e521eff824 100644 --- a/crates/bevy_pbr/src/render/mesh.rs +++ b/crates/bevy_pbr/src/render/mesh.rs @@ -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())); } } diff --git a/crates/bevy_render/src/extract_component.rs b/crates/bevy_render/src/extract_component.rs index 38a9b597fb762..a4ec525eaf171 100644 --- a/crates/bevy_render/src/extract_component.rs +++ b/crates/bevy_render/src/extract_component.rs @@ -187,7 +187,7 @@ fn extract_components( ) { 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); @@ -202,7 +202,7 @@ fn extract_visible_components( 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(); diff --git a/examples/2d/mesh2d_manual.rs b/examples/2d/mesh2d_manual.rs index d19a3a320a837..764701269ef7b 100644 --- a/examples/2d/mesh2d_manual.rs +++ b/examples/2d/mesh2d_manual.rs @@ -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); From fa1fa1af87e7a98f8eaebc41a5372104459908cf Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Sat, 29 Oct 2022 12:27:22 -0400 Subject: [PATCH 2/3] fix a clippy lint --- crates/bevy_ecs/src/query/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/query/mod.rs b/crates/bevy_ecs/src/query/mod.rs index f84c12339db65..44147b98d55db 100644 --- a/crates/bevy_ecs/src/query/mod.rs +++ b/crates/bevy_ecs/src/query/mod.rs @@ -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); From e2da90e342d15ff61d0cd2cf13945b85721f4575 Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Sat, 29 Oct 2022 12:49:36 -0400 Subject: [PATCH 3/3] remove more single-tuples --- crates/bevy_render/src/extract_component.rs | 4 ++-- crates/bevy_sprite/src/render/mod.rs | 2 +- crates/bevy_ui/src/render/mod.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/bevy_render/src/extract_component.rs b/crates/bevy_render/src/extract_component.rs index a4ec525eaf171..da90b0bcb423f 100644 --- a/crates/bevy_render/src/extract_component.rs +++ b/crates/bevy_render/src/extract_component.rs @@ -115,10 +115,10 @@ fn prepare_uniform_components( .map(|(entity, component)| { ( entity, - (DynamicUniformIndex:: { + DynamicUniformIndex:: { index: component_uniforms.uniforms.push(component.clone()), marker: PhantomData, - },), + }, ) }) .collect::>(); diff --git a/crates/bevy_sprite/src/render/mod.rs b/crates/bevy_sprite/src/render/mod.rs index c7a49d358cadc..70d07478ab91a 100644 --- a/crates/bevy_sprite/src/render/mod.rs +++ b/crates/bevy_sprite/src/render/mod.rs @@ -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 diff --git a/crates/bevy_ui/src/render/mod.rs b/crates/bevy_ui/src/render/mod.rs index 28301d5b9a16b..9ef419e6bc82b 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -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();