File tree 1 file changed +20
-1
lines changed
crates/bevy_ecs/src/storage
1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -171,7 +171,26 @@ impl ComponentSparseSet {
171
171
}
172
172
173
173
/// Removes all of the values stored within.
174
- pub ( crate ) fn clear ( & mut self ) { }
174
+ pub ( crate ) fn clear ( & mut self ) {
175
+ let Self {
176
+ entity_to_row,
177
+ free_rows,
178
+ buffer_len,
179
+ buffer_capacity : _,
180
+ column,
181
+ } = self ;
182
+
183
+ if let Some ( drop) = column. data . drop {
184
+ for row in entity_to_row. iter ( ) . filter_map ( |row| row. map ( |row| row. 0 ) ) {
185
+ // SAFETY: We have &mut and clearing all rows. This value will never be accessed again.
186
+ unsafe { drop ( column. data . get_unchecked_mut ( row. index ( ) ) . promote ( ) ) }
187
+ }
188
+ }
189
+
190
+ free_rows. clear ( ) ;
191
+ entity_to_row. clear ( ) ;
192
+ * buffer_len = 0 ;
193
+ }
175
194
176
195
/// Returns the number of component values in the sparse set.
177
196
#[ inline]
You can’t perform that action at this time.
0 commit comments