refactor: optimize query execution and improve change tracking

- Optimize `QueryExecutor` to use the smallest sparse set as a driver
  for multi-component queries, reducing iteration overhead.
- Implement automatic cleanup of unused `Subject` instances in
  `ChangeBuffer` using a subscriber count.
- Improve `ChangeSet` deduplication to correctly handle rapid
  add/remove transitions for the same component.
- Add validation to ensure `IRelationship` components are added to
  their declared `Source` entity.
- Update documentation to reflect correct `Entity` bit layout.
This commit is contained in:
2026-07-18 21:42:08 +08:00
parent 339e850e10
commit 32f4aa3e35
5 changed files with 450 additions and 71 deletions
+2 -2
View File
@@ -45,8 +45,8 @@ signature) and sparse sets (one dense array per component type).
**Context:** Entities need to be cheap to copy, comparable, and safe against
use-after-free (accessing a recycled entity ID).
**Decision:** `readonly struct Entity` wrapping a `uint`. Upper 24 bits are the
ID, lower 8 bits are the version.
**Decision:** `readonly struct Entity` wrapping a `uint`. Lower 24 bits are the
ID, upper 8 bits are the version.
**Rationale:**