Skip to content

Commit 60da25c

Browse files
Remove optimization suggestion in BufferVec::push() (#22479)
# Objective A comment in `BufferVec::push()` suggests a possible optimization that can't be implemented reasonably. Reword it. ## Solution Replace the comment with an explanation of why the seemingly suboptimal implementation is necessary. See the investigation in #22361.
1 parent c10c63a commit 60da25c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/bevy_render/src/render_resource/buffer_vec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,8 @@ where
348348

349349
// `extend` does not optimize for reallocation. Related `trusted_len` feature is unstable.
350350
self.data.reserve(self.data.len() + element_size);
351-
// TODO: Consider using unsafe code to push uninitialized, to prevent
352-
// the zeroing. It shows up in profiles.
351+
// We can't optimize and push uninitialized data here (using e.g. spare_capacity_mut())
352+
// because write_into() does not initialize inner padding bytes in T's expansion
353353
self.data.extend(iter::repeat_n(0, element_size));
354354

355355
// Take a slice of the new data for `write_into` to use. This is

0 commit comments

Comments
 (0)