Arch
Arch copied to clipboard
Cached `Query`s
Problem
Each Query currently iterates the whole list of Archetypes. This is bad for scenarios with many archetypes.
Instead each query should ONLY iterate archetypes that fits its description.
Solution
We need some way to map a Query to its Archetypes and a Archetype to its Querys in a decoupled way.
Therefore, we could add a QueryCache to the World that exactly does this mapping and validates the process.
public class QueryCache{
internal Dictionary<Query, List<Archetype>> QueryToArchetype;
internal Dictionary<Archetype, List<Query>> ArchetypeToQuerys;
}
Or as an alternative we put those lists directly into the Query and Archetype. This however would couple the classes to another which is generally not a great idea for refactoring and maintainability reasons.
the ecs project flecs query caches matched tables. can we use its implementation.
Introduced in 3c738541b942c08608f2ee3d6e56f687dedc7a88