diff options
author | HampusM <hampus@hampusmat.com> | 2024-12-22 12:23:06 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-12-22 12:23:44 +0100 |
commit | 098a2a44465b2062f1de1afc242aa1852f9d95a5 (patch) | |
tree | 56176f280657d44b4c830e6d60540c28b6d2a0ca | |
parent | cbb32d20e0156873098d89715801a5411a8137a5 (diff) |
perf(ecs): create string in Storage::push_entity log with cap
-rw-r--r-- | ecs/src/component/storage.rs | 12 |
1 files changed, 7 insertions, 5 deletions
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::<Vec<_>>() - .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( |