Skip to content

Commit 609de31

Browse files
committed
ci fix to run tests, come back to this commit in the future
1 parent cb54e7d commit 609de31

File tree

4 files changed

+13
-40
lines changed

4 files changed

+13
-40
lines changed

crates/bevy_ecs/src/entity/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,10 @@ pub type EntityIdLocation = Option<EntityLocation>;
13211321
/// An [`Entity`] that has been disabled. This entity will not be found by queries or accessible via other ECS operations, but it's components are still stored in the ECS.
13221322
/// This is useful for temporarily disabling an entity without fully despawning it or invoking archetype moves. This entity keeps track of its location, so it can be re-enabled later.
13231323
pub struct DisabledEntity {
1324+
/// The disabled entity.
13241325
pub entity: Entity,
1326+
/// The location of the entity after it was disabled.
1327+
/// This may not necessarily be it's location when it is re-enabled.
13251328
pub location: EntityLocation,
13261329
}
13271330

crates/bevy_ecs/src/storage/blob_array.rs

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use core::{
55
alloc::Layout,
66
cell::UnsafeCell,
77
num::NonZeroUsize,
8-
ops::{Bound, Range, RangeBounds},
8+
ops::{Bound, RangeBounds},
99
ptr::NonNull,
1010
};
1111

@@ -162,38 +162,6 @@ impl BlobArray {
162162
}
163163
}
164164

165-
/// Clears the array, i.e. removing (and dropping) all of the elements.
166-
/// Note that this method has no effect on the allocated capacity of the vector.
167-
///
168-
/// Note that this method will behave exactly the same as [`Vec::clear`].
169-
///
170-
/// # Safety
171-
/// - For every element with index `i`, if `i` < `len`: It must be safe to call [`Self::get_unchecked_mut`] with `i`.
172-
/// (If the safety requirements of every method that has been used on `Self` have been fulfilled, the caller just needs to ensure that `len` is correct.)
173-
///
174-
/// [`Vec::clear`]: alloc::vec::Vec::clear
175-
pub unsafe fn clear(&mut self, len: usize) {
176-
#[cfg(debug_assertions)]
177-
debug_assert!(self.capacity >= len);
178-
if let Some(drop) = self.drop {
179-
// We set `self.drop` to `None` before dropping elements for unwind safety. This ensures we don't
180-
// accidentally drop elements twice in the event of a drop impl panicking.
181-
self.drop = None;
182-
let size = self.item_layout.size();
183-
for i in 0..len {
184-
// SAFETY:
185-
// * 0 <= `i` < `len`, so `i * size` must be in bounds for the allocation.
186-
// * `size` is a multiple of the erased type's alignment,
187-
// so adding a multiple of `size` will preserve alignment.
188-
// * The item is left unreachable so it can be safely promoted to an `OwningPtr`.
189-
let item = unsafe { self.get_ptr_mut().byte_add(i * size).promote() };
190-
// SAFETY: `item` was obtained from this `BlobArray`, so its underlying type must match `drop`.
191-
unsafe { drop(item) };
192-
}
193-
self.drop = Some(drop);
194-
}
195-
}
196-
197165
/// Clears the array, i.e. removing (and dropping) all of the elements in the range.
198166
/// Note that this method has no effect on the allocated capacity of the vector.
199167
///
@@ -243,11 +211,11 @@ impl BlobArray {
243211
/// # Safety
244212
/// - `cap` and `len` are indeed the capacity and length of this [`BlobArray`]
245213
/// - This [`BlobArray`] mustn't be used after calling this method.
246-
pub unsafe fn drop(&mut self, cap: usize, len: usize) {
214+
pub unsafe fn drop(&mut self, cap: usize, range: impl RangeBounds<usize>) {
247215
#[cfg(debug_assertions)]
248216
debug_assert_eq!(self.capacity, cap);
249217
if cap != 0 {
250-
self.clear(len);
218+
self.clear_range(range);
251219
if !self.is_zst() {
252220
let layout =
253221
array_layout(&self.item_layout, cap).expect("array layout should be valid");

crates/bevy_ecs/src/storage/table/column.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ use crate::{
33
change_detection::MaybeLocation,
44
storage::{blob_array::BlobArray, thin_array_ptr::ThinArrayPtr},
55
};
6-
use core::{mem::needs_drop, panic::Location};
6+
use alloc::vec::Vec;
7+
use bevy_ptr::PtrMut;
8+
use core::{mem::needs_drop, ops::RangeBounds, panic::Location};
79

810
/// A type-erased contiguous container for data of a homogeneous type.
911
///
@@ -312,7 +314,7 @@ impl Column {
312314
pub(crate) unsafe fn clear(&mut self, len: usize) {
313315
self.added_ticks.clear_elements(len);
314316
self.changed_ticks.clear_elements(len);
315-
self.data.clear(len);
317+
self.data.clear_range(..len);
316318
self.changed_by
317319
.as_mut()
318320
.map(|changed_by| changed_by.clear_elements(len));
@@ -325,10 +327,10 @@ impl Column {
325327
/// - `len` is indeed the length of the column
326328
/// - `cap` is indeed the capacity of the column
327329
/// - the data stored in `self` will never be used again
328-
pub(crate) unsafe fn drop(&mut self, cap: usize, len: usize) {
330+
pub(crate) unsafe fn drop(&mut self, cap: usize, len: usize, range: impl RangeBounds<usize>) {
329331
self.added_ticks.drop(cap, len);
330332
self.changed_ticks.drop(cap, len);
331-
self.data.drop(cap, len);
333+
self.data.drop(cap, range);
332334
self.changed_by
333335
.as_mut()
334336
.map(|changed_by| changed_by.drop(cap, len));

crates/bevy_ecs/src/storage/table/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ impl Drop for Table {
933933
// SAFETY: `cap` and `len` are correct. `col` is never accessed again after this call.
934934
unsafe {
935935
// TODO: don't drop disabled entities components
936-
col.drop(cap, len);
936+
col.drop(cap, len, self.disabled_entities as usize..len);
937937
}
938938
}
939939
}

0 commit comments

Comments
 (0)