From 2a8718f7c671ab1fc5e38340b467e2bd77f16cc0 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 9 Feb 2025 18:41:26 +0100 Subject: perf(ecs): replace component::Sequence::into_vec fn with into_array --- ecs/src/component.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'ecs/src/component.rs') 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>; + type Array: Array>; + + fn into_array(self) -> Self::Array; fn metadata() -> impl Array; @@ -277,9 +279,11 @@ macro_rules! inner { { const COUNT: usize = $c + 1; - fn into_vec(self) -> Vec> + type Array = [Box; $c + 1]; + + fn into_array(self) -> Self::Array { - Vec::from_iter([#(Box::new(self.I) as Box,)*]) + [#(Box::new(self.I) as Box,)*] } fn metadata() -> impl Array @@ -356,11 +360,13 @@ seq!(C in 0..=16 { impl Sequence for () { + type Array = [Box; 0]; + const COUNT: usize = 0; - fn into_vec(self) -> Vec> + fn into_array(self) -> Self::Array { - Vec::new() + [] } fn metadata() -> impl Array -- cgit v1.2.3-18-g5258