From e7a9420443b204c154731b5c86167d09023612cf Mon Sep 17 00:00:00 2001 From: Boxy Date: Sat, 19 Mar 2022 04:14:27 +0000 Subject: [PATCH] Change `Cow<[ComponentId]>` to `Box<[ComponentId]>` (#4185) `Cow::Borrowed` was never used --- crates/bevy_ecs/src/archetype.rs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/crates/bevy_ecs/src/archetype.rs b/crates/bevy_ecs/src/archetype.rs index cb5cfba3ab..ab33119a93 100644 --- a/crates/bevy_ecs/src/archetype.rs +++ b/crates/bevy_ecs/src/archetype.rs @@ -8,7 +8,6 @@ use crate::{ storage::{Column, SparseArray, SparseSet, SparseSetIndex, TableId}, }; use std::{ - borrow::Cow, collections::HashMap, hash::Hash, ops::{Index, IndexMut}, @@ -121,8 +120,8 @@ pub struct Archetype { entities: Vec, edges: Edges, table_info: TableInfo, - table_components: Cow<'static, [ComponentId]>, - sparse_set_components: Cow<'static, [ComponentId]>, + table_components: Box<[ComponentId]>, + sparse_set_components: Box<[ComponentId]>, pub(crate) unique_components: SparseSet, pub(crate) components: SparseSet, } @@ -131,8 +130,8 @@ impl Archetype { pub fn new( id: ArchetypeId, table_id: TableId, - table_components: Cow<'static, [ComponentId]>, - sparse_set_components: Cow<'static, [ComponentId]>, + table_components: Box<[ComponentId]>, + sparse_set_components: Box<[ComponentId]>, table_archetype_components: Vec, sparse_set_archetype_components: Vec, ) -> Self { @@ -331,8 +330,8 @@ impl ArchetypeGeneration { #[derive(Hash, PartialEq, Eq)] pub struct ArchetypeIdentity { - table_components: Cow<'static, [ComponentId]>, - sparse_set_components: Cow<'static, [ComponentId]>, + table_components: Box<[ComponentId]>, + sparse_set_components: Box<[ComponentId]>, } #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] @@ -381,8 +380,8 @@ impl Default for Archetypes { archetypes.archetypes.push(Archetype::new( ArchetypeId::RESOURCE, TableId::empty(), - Cow::Owned(Vec::new()), - Cow::Owned(Vec::new()), + Box::new([]), + Box::new([]), Vec::new(), Vec::new(), )); @@ -477,8 +476,8 @@ impl Archetypes { table_components: Vec, sparse_set_components: Vec, ) -> ArchetypeId { - let table_components = Cow::from(table_components); - let sparse_set_components = Cow::from(sparse_set_components); + let table_components = table_components.into_boxed_slice(); + let sparse_set_components = sparse_set_components.into_boxed_slice(); let archetype_identity = ArchetypeIdentity { sparse_set_components: sparse_set_components.clone(), table_components: table_components.clone(),