remove some mut in queries (#3437)

# 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>
This commit is contained in:
François 2021-12-26 05:39:46 +00:00
parent 963e2f08a2
commit 585d0b8467
5 changed files with 9 additions and 9 deletions

View File

@ -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.

View File

@ -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 {

View File

@ -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>,
) {
@ -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())

View File

@ -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() {
@ -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) {

View File

@ -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>,
) {
@ -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())