Skip to content

Commit c641a90

Browse files
committed
StorageType parameter removed from ComponentDescriptor::new_resource (#3495)
# Objective Remove the `StorageType` parameter from `ComponentDescriptor::new_resource` as discussed in #3361. - fixes #3361 ## Solution - Parameter removed. - Basic docs added. ## Note Left a [comment](#3361 (comment)) about `SparseStorage` being the more reasonable choice. Co-authored-by: r4gus <[email protected]>
1 parent 3ac55f0 commit c641a90

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

crates/bevy_ecs/src/component.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,15 @@ impl ComponentDescriptor {
194194
}
195195
}
196196

197-
pub fn new_resource<T: Resource>(storage_type: StorageType) -> Self {
197+
/// Create a new `ComponentDescriptor` for a resource.
198+
///
199+
/// The [`StorageType`] for resources is always [`TableStorage`].
200+
pub fn new_resource<T: Resource>() -> Self {
198201
Self {
199202
name: std::any::type_name::<T>().to_string(),
200-
storage_type,
203+
// PERF: `SparseStorage` may actually be a more
204+
// reasonable choice as `storage_type` for resources.
205+
storage_type: StorageType::Table,
201206
is_send_and_sync: true,
202207
type_id: Some(TypeId::of::<T>()),
203208
layout: Layout::new::<T>(),
@@ -308,7 +313,7 @@ impl Components {
308313
// SAFE: The [`ComponentDescriptor`] matches the [`TypeId`]
309314
unsafe {
310315
self.get_or_insert_resource_with(TypeId::of::<T>(), || {
311-
ComponentDescriptor::new_resource::<T>(StorageType::default())
316+
ComponentDescriptor::new_resource::<T>()
312317
})
313318
}
314319
}

0 commit comments

Comments
 (0)