1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-16 00:33:54 +01:00

Refactor StorageJSON to keep loaded_integrations a set until its converted to JSON (#5793)

* Refactor StorageJSON to keep loaded_integrations a set until its converted to a dict

after #5792 we will be checking loaded_integrations often. ESPHome
core keep uses a set, but it would get converted to a list when
passed through StorageJSON. Keep it a set until its needed to
be read/write to JSON so we do not have to linear searches on it
since they have a time complexity of O(n) vs O(1)

* legacy
This commit is contained in:
J. Nick Koston
2023-11-19 21:31:00 -06:00
committed by GitHub
parent cd9bf29df1
commit 2aaee81313
2 changed files with 45 additions and 54 deletions

View File

@@ -285,7 +285,7 @@ class DashboardEntry:
"name": self.name,
"friendly_name": self.friendly_name,
"configuration": self.filename,
"loaded_integrations": self.loaded_integrations,
"loaded_integrations": sorted(self.loaded_integrations),
"deployed_version": self.update_old,
"current_version": self.update_new,
"path": self.path,
@@ -381,7 +381,7 @@ class DashboardEntry:
return const.__version__
@property
def loaded_integrations(self) -> list[str]:
def loaded_integrations(self) -> set[str]:
if self.storage is None:
return []
return self.storage.loaded_integrations