Skip to content

Commit

Permalink
remove some mut in queries (#3437)
Browse files Browse the repository at this point in the history
# Objective

- While reading code, found some queries that are `mut` and not used as such

## Solution

- Remove `mut` when possible


Co-authored-by: François <8672791+mockersf@users.noreply.github.com>
  • Loading branch information
mockersf and mockersf committed Dec 26, 2021
1 parent 963e2f0 commit 585d0b8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/system/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ use thiserror::Error;
/// # struct ComponentA;
/// # #[derive(Component)]
/// # struct ComponentB;
/// fn immutable_query_system(mut query: Query<(&ComponentA, &ComponentB)>) {
/// fn immutable_query_system(query: Query<(&ComponentA, &ComponentB)>) {
/// for (a, b) in query.iter() {
/// // Here, `a` and `b` are normal references to components, relatively of
/// // `&ComponentA` and `&ComponentB` types.
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_pbr/src/render/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,14 +584,14 @@ pub fn queue_mesh_view_bind_groups(
light_meta: Res<LightMeta>,
global_light_meta: Res<GlobalLightMeta>,
view_uniforms: Res<ViewUniforms>,
mut views: Query<(Entity, &ViewShadowBindings, &ViewClusterBindings)>,
views: Query<(Entity, &ViewShadowBindings, &ViewClusterBindings)>,
) {
if let (Some(view_binding), Some(light_binding), Some(point_light_binding)) = (
view_uniforms.uniforms.binding(),
light_meta.view_gpu_lights.binding(),
global_light_meta.gpu_point_lights.binding(),
) {
for (entity, view_shadow_bindings, view_cluster_bindings) in views.iter_mut() {
for (entity, view_shadow_bindings, view_cluster_bindings) in views.iter() {
let view_bind_group = render_device.create_bind_group(&BindGroupDescriptor {
entries: &[
BindGroupEntry {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_sprite/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ pub fn queue_sprites(
mut pipeline_cache: ResMut<RenderPipelineCache>,
mut image_bind_groups: ResMut<ImageBindGroups>,
gpu_images: Res<RenderAssets<Image>>,
mut sprite_batches: Query<(Entity, &SpriteBatch)>,
sprite_batches: Query<(Entity, &SpriteBatch)>,
mut views: Query<&mut RenderPhase<Transparent2d>>,
events: Res<SpriteAssetEvents>,
) {
Expand Down Expand Up @@ -514,7 +514,7 @@ pub fn queue_sprites(
SpritePipelineKey { colored: true },
);
for mut transparent_phase in views.iter_mut() {
for (entity, batch) in sprite_batches.iter_mut() {
for (entity, batch) in sprite_batches.iter() {
image_bind_groups
.values
.entry(batch.handle.clone_weak())
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_text/src/text2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn extract_text2d_sprite(
texture_atlases: Res<Assets<TextureAtlas>>,
text_pipeline: Res<DefaultTextPipeline>,
windows: Res<Windows>,
mut text2d_query: Query<(Entity, &Text, &GlobalTransform, &Text2dSize)>,
text2d_query: Query<(Entity, &Text, &GlobalTransform, &Text2dSize)>,
) {
let mut extracted_sprites = render_world.get_resource_mut::<ExtractedSprites>().unwrap();
let scale_factor = if let Some(window) = windows.get_primary() {
Expand All @@ -53,7 +53,7 @@ pub fn extract_text2d_sprite(
1.
};

for (entity, text, transform, calculated_size) in text2d_query.iter_mut() {
for (entity, text, transform, calculated_size) in text2d_query.iter() {
let (width, height) = (calculated_size.size.width, calculated_size.size.height);

if let Some(text_layout) = text_pipeline.get_glyphs(&entity) {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ui/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ pub fn queue_uinodes(
mut pipeline_cache: ResMut<RenderPipelineCache>,
mut image_bind_groups: ResMut<UiImageBindGroups>,
gpu_images: Res<RenderAssets<Image>>,
mut ui_batches: Query<(Entity, &UiBatch)>,
ui_batches: Query<(Entity, &UiBatch)>,
mut views: Query<&mut RenderPhase<TransparentUi>>,
events: Res<SpriteAssetEvents>,
) {
Expand All @@ -441,7 +441,7 @@ pub fn queue_uinodes(
let draw_ui_function = draw_functions.read().get_id::<DrawUi>().unwrap();
let pipeline = pipelines.specialize(&mut pipeline_cache, &ui_pipeline, UiPipelineKey {});
for mut transparent_phase in views.iter_mut() {
for (entity, batch) in ui_batches.iter_mut() {
for (entity, batch) in ui_batches.iter() {
image_bind_groups
.values
.entry(batch.image.clone_weak())
Expand Down

0 comments on commit 585d0b8

Please sign in to comment.