summaryrefslogtreecommitdiff
path: root/ecs/src/component.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2025-02-09 18:41:26 +0100
committerHampusM <hampus@hampusmat.com>2025-02-09 18:41:26 +0100
commit2a8718f7c671ab1fc5e38340b467e2bd77f16cc0 (patch)
tree15d2eba5c57b484c89d3f5e11fe41deebbd1f92e /ecs/src/component.rs
parentc06d59ffa09e22a98647f5104944e1c13b161963 (diff)
perf(ecs): replace component::Sequence::into_vec fn with into_array
Diffstat (limited to 'ecs/src/component.rs')
-rw-r--r--ecs/src/component.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/ecs/src/component.rs b/ecs/src/component.rs
index f5aa0d1..b2ecf80 100644
--- a/ecs/src/component.rs
+++ b/ecs/src/component.rs
@@ -167,7 +167,9 @@ pub trait Sequence
/// The number of components in this component sequence.
const COUNT: usize;
- fn into_vec(self) -> Vec<Box<dyn Component>>;
+ type Array: Array<Box<dyn Component>>;
+
+ fn into_array(self) -> Self::Array;
fn metadata() -> impl Array<Metadata>;
@@ -277,9 +279,11 @@ macro_rules! inner {
{
const COUNT: usize = $c + 1;
- fn into_vec(self) -> Vec<Box<dyn Component>>
+ type Array = [Box<dyn Component>; $c + 1];
+
+ fn into_array(self) -> Self::Array
{
- Vec::from_iter([#(Box::new(self.I) as Box<dyn Component>,)*])
+ [#(Box::new(self.I) as Box<dyn Component>,)*]
}
fn metadata() -> impl Array<Metadata>
@@ -356,11 +360,13 @@ seq!(C in 0..=16 {
impl Sequence for ()
{
+ type Array = [Box<dyn Component>; 0];
+
const COUNT: usize = 0;
- fn into_vec(self) -> Vec<Box<dyn Component>>
+ fn into_array(self) -> Self::Array
{
- Vec::new()
+ []
}
fn metadata() -> impl Array<Metadata>