ECS systems need to query the "world" for all entities with the requested set of components. Systems may also need to run every frame, and so caching these queries would constitute a significant improvement to the performance of the application.
Queries can be cached in a hashmap that maps a set of components to an array with all entities that share those components.
The problem is signalling the cache that an entity has gained/lost a component so it is re-run. When this happens, on the AddComponent or RemoveComponent functions, one would have to iterate over all cached queries to find those that share that component and tell them to reset themselves, which could be more expensive than just not caching them.
ECS systems need to query the "world" for all entities with the requested set of components. Systems may also need to run every frame, and so caching these queries would constitute a significant improvement to the performance of the application. Queries can be cached in a hashmap that maps a set of components to an array with all entities that share those components.
The problem is signalling the cache that an entity has gained/lost a component so it is re-run. When this happens, on the AddComponent or RemoveComponent functions, one would have to iterate over all cached queries to find those that share that component and tell them to reset themselves, which could be more expensive than just not caching them.