At the moment EntityArchetype.GetComponentTypes requires always allocating a new NativeArray which can be slow depending on how often it's called. I'm thinking the API could either:
- Provide a NativeList<ComponentType> overload that just appends the archetype components to the list, then the list can be reused.
- Provide out of the box an extremely short lived allocator (maybe one that can use stack allocated memory?) that can be manually rewinded.
- Provide readonly access to the currently internal ComponentTypeInArchetype* Types
Currently EntityArchetype.CalculateDifference can be used to somewhat work around this but it isn't very ergonomic. EntityArchetype.GetComponentTypes is often useful along with SetArchetype to make multiple structural changes in one single method call.