diff --git a/crates/bevy_ecs/src/component.rs b/crates/bevy_ecs/src/component.rs index a38132fc4c435..92ade0560df57 100644 --- a/crates/bevy_ecs/src/component.rs +++ b/crates/bevy_ecs/src/component.rs @@ -194,10 +194,15 @@ impl ComponentDescriptor { } } - pub fn new_resource(storage_type: StorageType) -> Self { + /// Create a new `ComponentDescriptor` for a resource. + /// + /// The [`StorageType`] for resources is always [`TableStorage`]. + pub fn new_resource() -> Self { Self { name: std::any::type_name::().to_string(), - storage_type, + // PERF: `SparseStorage` may actually be a more + // reasonable choice as `storage_type` for resources. + storage_type: StorageType::Table, is_send_and_sync: true, type_id: Some(TypeId::of::()), layout: Layout::new::(), @@ -308,7 +313,7 @@ impl Components { // SAFE: The [`ComponentDescriptor`] matches the [`TypeId`] unsafe { self.get_or_insert_resource_with(TypeId::of::(), || { - ComponentDescriptor::new_resource::(StorageType::default()) + ComponentDescriptor::new_resource::() }) } }