Skip to content

Commit d506de5

Browse files
committed
small code improvement
1 parent 725cba2 commit d506de5

File tree

1 file changed

+7
-11
lines changed
  • crates/bevy_sprite/src/render

1 file changed

+7
-11
lines changed

crates/bevy_sprite/src/render/mod.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -474,19 +474,15 @@ pub fn prepare_sprites(
474474
z_order = extracted_sprite.transform.translation.z;
475475
}
476476
// if start != end, there is one last batch to process
477-
if white_start != white_end {
477+
let [start, end] = match current_batch_colored {
478+
true => [&mut colored_start, &mut colored_end],
479+
false => [&mut white_start, &mut white_end],
480+
};
481+
if *start != *end {
478482
commands.spawn().insert(SpriteBatch {
479-
range: white_start..white_end,
483+
range: *start..*end,
480484
image_handle_id: current_batch_handle,
481-
colored: false,
482-
z_order,
483-
});
484-
}
485-
if colored_start != colored_end {
486-
commands.spawn().insert(SpriteBatch {
487-
range: colored_start..colored_end,
488-
image_handle_id: current_batch_handle,
489-
colored: true,
485+
colored: current_batch_colored,
490486
z_order,
491487
});
492488
}

0 commit comments

Comments
 (0)