Skip to content

Commit

Permalink
Remove unnecessary dictionary lookup inside has_components (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
m4reQ authored Aug 21, 2024
1 parent 6a56755 commit f5dbf64
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion esper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ def has_component(entity: int, component_type: _Type[_C]) -> bool:

def has_components(entity: int, *component_types: _Type[_C]) -> bool:
"""Check if an Entity has all the specified Component types."""
return all(comp_type in _entities[entity] for comp_type in component_types)
components_dict = _entities[entity]
return all(comp_type in components_dict for comp_type in component_types)


def add_component(entity: int, component_instance: _C, type_alias: _Optional[_Type[_C]] = None) -> None:
Expand Down

0 comments on commit f5dbf64

Please sign in to comment.