mirror of
https://github.com/bevyengine/bevy
synced 2024-09-20 14:32:06 +00:00
Fix clippy::iter_with_drain
(#6485)
# Objective Fixes #6483. - Fix the [`clippy::iter_with_drain`](https://rust-lang.github.io/rust-clippy/master/index.html#iter_with_drain) warnings - From the docs: "`.into_iter()` is simpler with better performance" ## Solution - Replace `.drain(..)` for `Vec` with `.into_iter()`
This commit is contained in:
parent
66f495c44e
commit
694c980c82
8 changed files with 16 additions and 17 deletions
|
@ -86,8 +86,8 @@ impl<T: Asset> LoadedAsset<T> {
|
||||||
|
|
||||||
/// Adds dependencies on other assets at the provided paths.
|
/// Adds dependencies on other assets at the provided paths.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_dependencies(mut self, mut asset_paths: Vec<AssetPath<'static>>) -> Self {
|
pub fn with_dependencies(mut self, asset_paths: Vec<AssetPath<'static>>) -> Self {
|
||||||
for asset_path in asset_paths.drain(..) {
|
for asset_path in asset_paths {
|
||||||
self.add_dependency(asset_path);
|
self.add_dependency(asset_path);
|
||||||
}
|
}
|
||||||
self
|
self
|
||||||
|
|
|
@ -235,9 +235,9 @@ fn find_ambiguities(systems: &[SystemContainer]) -> Vec<(usize, usize, Vec<Compo
|
||||||
}
|
}
|
||||||
all_dependants[index] = dependants;
|
all_dependants[index] = dependants;
|
||||||
}
|
}
|
||||||
let mut all_relations = all_dependencies
|
let all_relations = all_dependencies
|
||||||
.drain(..)
|
.into_iter()
|
||||||
.zip(all_dependants.drain(..))
|
.zip(all_dependants.into_iter())
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(index, (dependencies, dependants))| {
|
.map(|(index, (dependencies, dependants))| {
|
||||||
let mut relations = FixedBitSet::with_capacity(systems.len());
|
let mut relations = FixedBitSet::with_capacity(systems.len());
|
||||||
|
@ -250,7 +250,7 @@ fn find_ambiguities(systems: &[SystemContainer]) -> Vec<(usize, usize, Vec<Compo
|
||||||
let mut ambiguities = Vec::new();
|
let mut ambiguities = Vec::new();
|
||||||
let full_bitset: FixedBitSet = (0..systems.len()).collect();
|
let full_bitset: FixedBitSet = (0..systems.len()).collect();
|
||||||
let mut processed = FixedBitSet::with_capacity(systems.len());
|
let mut processed = FixedBitSet::with_capacity(systems.len());
|
||||||
for (index_a, relations) in all_relations.drain(..).enumerate() {
|
for (index_a, relations) in all_relations.into_iter().enumerate() {
|
||||||
// TODO: prove that `.take(index_a)` would be correct here, and uncomment it if so.
|
// TODO: prove that `.take(index_a)` would be correct here, and uncomment it if so.
|
||||||
for index_b in full_bitset.difference(&relations)
|
for index_b in full_bitset.difference(&relations)
|
||||||
// .take(index_a)
|
// .take(index_a)
|
||||||
|
|
|
@ -309,7 +309,7 @@ impl SystemStage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
for system in systems.drain(..) {
|
for system in systems {
|
||||||
self.add_system_inner(system, set_run_criteria_index);
|
self.add_system_inner(system, set_run_criteria_index);
|
||||||
}
|
}
|
||||||
self
|
self
|
||||||
|
|
|
@ -203,12 +203,12 @@ fn assert_component_access_compatibility(
|
||||||
current: &FilteredAccess<ComponentId>,
|
current: &FilteredAccess<ComponentId>,
|
||||||
world: &World,
|
world: &World,
|
||||||
) {
|
) {
|
||||||
let mut conflicts = system_access.get_conflicts_single(current);
|
let conflicts = system_access.get_conflicts_single(current);
|
||||||
if conflicts.is_empty() {
|
if conflicts.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let conflicting_components = conflicts
|
let conflicting_components = conflicts
|
||||||
.drain(..)
|
.into_iter()
|
||||||
.map(|component_id| world.components.get_info(component_id).unwrap().name())
|
.map(|component_id| world.components.get_info(component_id).unwrap().name())
|
||||||
.collect::<Vec<&str>>();
|
.collect::<Vec<&str>>();
|
||||||
let accesses = conflicting_components.join(", ");
|
let accesses = conflicting_components.join(", ");
|
||||||
|
|
|
@ -536,8 +536,8 @@ fn prepare_materials<M: Material>(
|
||||||
fallback_image: Res<FallbackImage>,
|
fallback_image: Res<FallbackImage>,
|
||||||
pipeline: Res<MaterialPipeline<M>>,
|
pipeline: Res<MaterialPipeline<M>>,
|
||||||
) {
|
) {
|
||||||
let mut queued_assets = std::mem::take(&mut prepare_next_frame.assets);
|
let queued_assets = std::mem::take(&mut prepare_next_frame.assets);
|
||||||
for (handle, material) in queued_assets.drain(..) {
|
for (handle, material) in queued_assets.into_iter() {
|
||||||
match prepare_material(
|
match prepare_material(
|
||||||
&material,
|
&material,
|
||||||
&render_device,
|
&render_device,
|
||||||
|
|
|
@ -186,8 +186,8 @@ fn prepare_assets<R: RenderAsset>(
|
||||||
param: StaticSystemParam<<R as RenderAsset>::Param>,
|
param: StaticSystemParam<<R as RenderAsset>::Param>,
|
||||||
) {
|
) {
|
||||||
let mut param = param.into_inner();
|
let mut param = param.into_inner();
|
||||||
let mut queued_assets = std::mem::take(&mut prepare_next_frame.assets);
|
let queued_assets = std::mem::take(&mut prepare_next_frame.assets);
|
||||||
for (handle, extracted_asset) in queued_assets.drain(..) {
|
for (handle, extracted_asset) in queued_assets {
|
||||||
match R::prepare_asset(extracted_asset, &mut param) {
|
match R::prepare_asset(extracted_asset, &mut param) {
|
||||||
Ok(prepared_asset) => {
|
Ok(prepared_asset) => {
|
||||||
render_assets.insert(handle, prepared_asset);
|
render_assets.insert(handle, prepared_asset);
|
||||||
|
|
|
@ -35,8 +35,7 @@ impl<I: BatchedPhaseItem> RenderPhase<I> {
|
||||||
/// Batches the compatible [`BatchedPhaseItem`]s of this render phase
|
/// Batches the compatible [`BatchedPhaseItem`]s of this render phase
|
||||||
pub fn batch(&mut self) {
|
pub fn batch(&mut self) {
|
||||||
// TODO: this could be done in-place
|
// TODO: this could be done in-place
|
||||||
let mut items = std::mem::take(&mut self.items);
|
let mut items = std::mem::take(&mut self.items).into_iter();
|
||||||
let mut items = items.drain(..);
|
|
||||||
|
|
||||||
self.items.reserve(items.len());
|
self.items.reserve(items.len());
|
||||||
|
|
||||||
|
|
|
@ -471,8 +471,8 @@ fn prepare_materials_2d<M: Material2d>(
|
||||||
fallback_image: Res<FallbackImage>,
|
fallback_image: Res<FallbackImage>,
|
||||||
pipeline: Res<Material2dPipeline<M>>,
|
pipeline: Res<Material2dPipeline<M>>,
|
||||||
) {
|
) {
|
||||||
let mut queued_assets = std::mem::take(&mut prepare_next_frame.assets);
|
let queued_assets = std::mem::take(&mut prepare_next_frame.assets);
|
||||||
for (handle, material) in queued_assets.drain(..) {
|
for (handle, material) in queued_assets {
|
||||||
match prepare_material2d(
|
match prepare_material2d(
|
||||||
&material,
|
&material,
|
||||||
&render_device,
|
&render_device,
|
||||||
|
|
Loading…
Reference in a new issue