From 098a2a44465b2062f1de1afc242aa1852f9d95a5 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 22 Dec 2024 12:23:06 +0100 Subject: perf(ecs): create string in Storage::push_entity log with cap --- ecs/src/component/storage.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'ecs/src/component/storage.rs') diff --git a/ecs/src/component/storage.rs b/ecs/src/component/storage.rs index e1523df..5098c5f 100644 --- a/ecs/src/component/storage.rs +++ b/ecs/src/component/storage.rs @@ -96,11 +96,13 @@ impl Storage #[cfg(feature = "debug")] tracing::debug!( "Pushing entity with components: ({})", - components - .iter() - .map(|component| component.type_name()) - .collect::>() - .join(", ") + &components.iter().fold( + String::with_capacity(components.len() * 25), + |mut acc, component| { + acc.extend([", ", component.type_name()]); + acc + } + )[2..] ); let archetype_id = ArchetypeId::from_components_metadata( -- cgit v1.2.3-18-g5258