mirror of
https://github.com/home-assistant/core.git
synced 2025-08-07 14:45:09 +02:00
Avoid linear search to remove a label from the entity registry (#115674)
* Avoid linear search to remove a label from the entity registry * simplify
This commit is contained in:
@@ -1329,11 +1329,8 @@ class EntityRegistry(BaseRegistry):
|
||||
@callback
|
||||
def async_clear_label_id(self, label_id: str) -> None:
|
||||
"""Clear label from registry entries."""
|
||||
for entity_id, entry in self.entities.items():
|
||||
if label_id in entry.labels:
|
||||
labels = entry.labels.copy()
|
||||
labels.remove(label_id)
|
||||
self.async_update_entity(entity_id, labels=labels)
|
||||
for entry in self.entities.get_entries_for_label(label_id):
|
||||
self.async_update_entity(entry.entity_id, labels=entry.labels - {label_id})
|
||||
|
||||
@callback
|
||||
def async_clear_config_entry(self, config_entry_id: str) -> None:
|
||||
|
Reference in New Issue
Block a user