Skip to content

Commit 75aa668

Browse files
committed
perf: Minor optimization in Entity._update_tags: Use get instead of items
1 parent 79f4f53 commit 75aa668

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

hearthstone/entities.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ def zone(self):
4545
return self.tags.get(GameTag.ZONE, Zone.INVALID)
4646

4747
def _update_tags(self, tags):
48-
for tag, value in tags.items():
49-
if tag == GameTag.CONTROLLER and not self._initial_controller:
50-
self._initial_controller = self.tags.get(GameTag.CONTROLLER, value)
48+
controller = tags.get(GameTag.CONTROLLER)
49+
if controller is not None and not self._initial_controller:
50+
self._initial_controller = self.tags.get(GameTag.CONTROLLER, controller)
51+
5152
self.tags.update(tags)
5253

5354
def reset(self):
@@ -161,7 +162,7 @@ def reset(self) -> None:
161162

162163
def find_entity_by_id(self, id: int) -> Optional[Entity]:
163164
# int() for LazyPlayer mainly...
164-
id = int(id)
165+
# id = int(id)
165166
return self._entities.get(id)
166167

167168

0 commit comments

Comments
 (0)