Avoid linear search in homekit to find devices (#114808)

This commit is contained in:
J. Nick Koston 2024-04-03 23:39:16 -10:00 committed by GitHub
parent 86feae421c
commit 5be5c37326
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -953,9 +953,8 @@ class HomeKit:
"""Purge bridges that exist from failed pairing or manual resets.""" """Purge bridges that exist from failed pairing or manual resets."""
devices_to_purge = [ devices_to_purge = [
entry.id entry.id
for entry in dev_reg.devices.values() for entry in dev_reg.devices.get_devices_for_config_entry_id(self._entry_id)
if self._entry_id in entry.config_entries if (
and (
identifier not in entry.identifiers # type: ignore[comparison-overlap] identifier not in entry.identifiers # type: ignore[comparison-overlap]
or connection not in entry.connections or connection not in entry.connections
) )