Skip to content

Commit 59a0def

Browse files
committed
Formatting and CI fixes
1 parent ae50e04 commit 59a0def

File tree

4 files changed

+67
-38
lines changed

4 files changed

+67
-38
lines changed

crates/bevy_ecs/src/storage/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ pub use resource::*;
3030
pub use sparse_set::*;
3131
pub use table::*;
3232

33-
use alloc::vec::Vec;
3433
use crate::component::{ComponentInfo, StorageType};
34+
use alloc::vec::Vec;
3535

3636
/// The raw data stores of a [`World`](crate::world::World)
3737
#[derive(Default)]
@@ -84,4 +84,4 @@ impl<T> VecExtensions<T> for Vec<T> {
8484
core::ptr::copy_nonoverlapping(base_ptr.add(len - 1), base_ptr.add(index), 1);
8585
self.set_len(len - 1);
8686
}
87-
}
87+
}

crates/bevy_ecs/src/storage/sparse_set.rs

Lines changed: 58 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
use crate::{
2-
change_detection::MaybeLocation, component::{CheckChangeTicks, ComponentId, ComponentInfo, ComponentTicks, Tick, TickCells}, entity::{Entity, EntityRow}, query::DebugCheckedUnwrap, storage::{AbortOnPanic, TableRow, ThinColumn},
2+
change_detection::MaybeLocation,
3+
component::{CheckChangeTicks, ComponentId, ComponentInfo, ComponentTicks, Tick, TickCells},
4+
entity::{Entity, EntityRow},
5+
query::DebugCheckedUnwrap,
36
storage::VecExtensions,
7+
storage::{AbortOnPanic, TableRow, ThinColumn},
48
};
59
use alloc::{boxed::Box, vec::Vec};
610
use bevy_ptr::{OwningPtr, Ptr};
@@ -333,19 +337,32 @@ impl ComponentSparseSet {
333337
// SAFETY: TODO
334338
unsafe { self.entities.set_len(dense_index.index()) };
335339
// SAFETY: TODO
336-
unsafe { self.dense.get_data_unchecked(dense_index).assert_unique().promote() }
340+
unsafe {
341+
self.dense
342+
.get_data_unchecked(dense_index)
343+
.assert_unique()
344+
.promote()
345+
}
337346
} else {
338347
// SAFETY: TODO
339-
unsafe { self.entities.swap_remove_nonoverlapping_unchecked(dense_index.index()) };
348+
unsafe {
349+
self.entities
350+
.swap_remove_nonoverlapping_unchecked(dense_index.index());
351+
};
340352
// SAFETY: TODO
341353
let swapped_entity = unsafe { self.entities.get_unchecked(dense_index.index()) };
342354
#[cfg(not(debug_assertions))]
343355
let index = swapped_entity;
344356
#[cfg(debug_assertions)]
345357
let index = swapped_entity.row();
346-
unsafe { *self.sparse.get_mut(index).debug_checked_unwrap() = dense_index; }
358+
unsafe {
359+
*self.sparse.get_mut(index).debug_checked_unwrap() = dense_index;
360+
}
347361
// SAFETY: dense_index was just removed from `sparse`, which ensures that it is valid
348-
unsafe { self.dense.swap_remove_and_forget_unchecked(len, dense_index) }
362+
unsafe {
363+
self.dense
364+
.swap_remove_and_forget_unchecked(len, dense_index)
365+
}
349366
}
350367
})
351368
}
@@ -354,31 +371,43 @@ impl ComponentSparseSet {
354371
///
355372
/// Returns `true` if `entity` had a component value in the sparse set.
356373
pub(crate) fn remove(&mut self, entity: Entity) -> bool {
357-
self.sparse.remove(entity.row()).map(|dense_index| {
358-
#[cfg(debug_assertions)]
359-
assert_eq!(entity, self.entities[dense_index.index()]);
360-
let len = self.entities.len();
361-
if dense_index.index() >= len - 1 {
374+
self.sparse
375+
.remove(entity.row())
376+
.map(|dense_index| {
362377
#[cfg(debug_assertions)]
363-
assert_eq!(dense_index.index(), len - 1);
364-
// SAFETY: TODO
365-
unsafe { self.entities.set_len(dense_index.index()) };
366-
// SAFETY: TODO
367-
unsafe { self.dense.drop_last_component(dense_index.index()) };
368-
} else {
369-
// SAFETY: TODO
370-
unsafe { self.entities.swap_remove_nonoverlapping_unchecked(dense_index.index()) };
371-
// SAFETY: TODO
372-
let swapped_entity = unsafe { self.entities.get_unchecked(dense_index.index()) };
373-
#[cfg(not(debug_assertions))]
374-
let index = swapped_entity;
375-
#[cfg(debug_assertions)]
376-
let index = swapped_entity.row();
377-
unsafe { *self.sparse.get_mut(index).debug_checked_unwrap() = dense_index; }
378-
// SAFETY: TODO
379-
unsafe { self.dense.swap_remove_and_drop_unchecked_nonoverlapping(len, dense_index) };
380-
}
381-
}).is_some()
378+
assert_eq!(entity, self.entities[dense_index.index()]);
379+
let len = self.entities.len();
380+
if dense_index.index() >= len - 1 {
381+
#[cfg(debug_assertions)]
382+
assert_eq!(dense_index.index(), len - 1);
383+
// SAFETY: TODO
384+
unsafe { self.entities.set_len(dense_index.index()) };
385+
// SAFETY: TODO
386+
unsafe { self.dense.drop_last_component(dense_index.index()) };
387+
} else {
388+
// SAFETY: TODO
389+
unsafe {
390+
self.entities
391+
.swap_remove_nonoverlapping_unchecked(dense_index.index());
392+
};
393+
// SAFETY: TODO
394+
let swapped_entity =
395+
unsafe { self.entities.get_unchecked(dense_index.index()) };
396+
#[cfg(not(debug_assertions))]
397+
let index = swapped_entity;
398+
#[cfg(debug_assertions)]
399+
let index = swapped_entity.row();
400+
unsafe {
401+
*self.sparse.get_mut(index).debug_checked_unwrap() = dense_index;
402+
}
403+
// SAFETY: TODO
404+
unsafe {
405+
self.dense
406+
.swap_remove_and_drop_unchecked_nonoverlapping(len, dense_index);
407+
};
408+
}
409+
})
410+
.is_some()
382411
}
383412

384413
pub(crate) fn check_change_ticks(&mut self, check: CheckChangeTicks) {

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ impl ThinColumn {
9191
last_element_index: usize,
9292
row: TableRow,
9393
) -> OwningPtr<'_> {
94-
let data = self.data
94+
let data = self
95+
.data
9596
.swap_remove_unchecked_nonoverlapping(row.index(), last_element_index);
9697
self.added_ticks
9798
.swap_remove_unchecked_nonoverlapping(row.index(), last_element_index);
@@ -372,9 +373,9 @@ impl ThinColumn {
372373
&self,
373374
row: TableRow,
374375
) -> MaybeLocation<&UnsafeCell<&'static Location<'static>>> {
375-
self.changed_by.as_ref().map(|changed_by| {
376-
changed_by.get_unchecked(row.index())
377-
})
376+
self.changed_by
377+
.as_ref()
378+
.map(|changed_by| changed_by.get_unchecked(row.index()))
378379
}
379380

380381
/// Fetches the "added" change detection tick for the value at `row`. Unlike [`Column::get_added_tick`]
@@ -416,4 +417,4 @@ impl ThinColumn {
416417
pub fn get_drop(&self) -> Option<unsafe fn(OwningPtr<'_>)> {
417418
self.data.get_drop()
418419
}
419-
}
420+
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ use crate::{
33
component::{CheckChangeTicks, ComponentId, ComponentInfo, ComponentTicks, Components, Tick},
44
entity::Entity,
55
query::DebugCheckedUnwrap,
6-
storage::{blob_vec::BlobVec, ImmutableSparseSet, SparseSet},
6+
storage::{ImmutableSparseSet, SparseSet},
77
};
88
use alloc::{boxed::Box, vec, vec::Vec};
99
use bevy_platform::collections::HashMap;
1010
use bevy_ptr::{OwningPtr, Ptr, UnsafeCellDeref};
1111
pub use column::*;
1212
use core::{
13-
alloc::Layout,
1413
cell::UnsafeCell,
1514
num::NonZeroUsize,
1615
ops::{Index, IndexMut},

0 commit comments

Comments
 (0)