Skip to content

refactor!: optimize component state lookups in GameObjectView #178

@ThorstenSuckow

Description

@ThorstenSuckow

Summary

The hasEnabledComponents() and hasDisabledComponents() checks in GameObjectView.h perform hash lookups during iteration, which is expensive for large entity counts.

Problem

When filtering GameObjects by component state using GameObjectFilter::ComponentEnabled or GameObjectFilter::ComponentDisabled, the current implementation performs hash map lookups for each entity during iteration. This becomes a performance bottleneck in scenarios with many entities.

Proposed Solution

Consider one of the following approaches:

  • Cache component enabled/disabled state directly on the GameObject as a boolean flag
  • Use a bitset or similar O(1) lookup structure instead of hash-based lookups
  • Maintain separate lists for enabled/disabled components to avoid per-entity checks

Acceptance Criteria

  • Component state checks during iteration are O(1)
  • No regression in correctness of filtering behavior
  • Benchmark comparison showing improvement for large entity counts

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions