Reduce overhead to lookup items in the entity and device registry (#94568)

This commit is contained in:
J. Nick Koston 2023-06-14 08:47:18 -10:00 committed by GitHub
parent de62082605
commit a0c023d5cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 6 deletions

View file

@ -509,6 +509,7 @@ def mock_registry(
if mock_entries is None:
mock_entries = {}
registry.entities = er.EntityRegistryItems()
registry._entities_data = registry.entities.data
for key, entry in mock_entries.items():
registry.entities[key] = entry
@ -554,6 +555,7 @@ def mock_device_registry(
"""
registry = dr.DeviceRegistry(hass)
registry.devices = dr.DeviceRegistryItems()
registry._device_data = registry.devices.data
if mock_entries is None:
mock_entries = {}
for key, entry in mock_entries.items():