Skip to content

Commit 1d3f878

Browse files
committed
bevy_pbr: Use Vec::append instead of a for loop and Vec::drain
1 parent 61872df commit 1d3f878

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

crates/bevy_pbr/src/render/light.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,7 @@ impl GpuPointLights {
142142
buffer.push(gpu_point_lights.try_into().unwrap());
143143
}
144144
GpuPointLights::Storage { buffer } => {
145-
for light in lights.drain(..) {
146-
buffer.push(light);
147-
}
145+
buffer.append(&mut lights);
148146
}
149147
}
150148
}

crates/bevy_render/src/render_resource/storage_buffer.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,9 @@ impl<T: AsStd430, U: AsStd430> StorageBuffer<T, U> {
161161
pub fn push(&mut self, value: T) {
162162
self.values.push(value);
163163
}
164+
165+
#[inline]
166+
pub fn append(&mut self, values: &mut Vec<T>) {
167+
self.values.append(values);
168+
}
164169
}

0 commit comments

Comments
 (0)