mirror of
https://github.com/home-assistant/core.git
synced 2025-12-26 14:08:21 +00:00
Add a fast path for async_get_platform (#113917)
This commit is contained in:
@@ -1065,7 +1065,11 @@ class Integration:
|
||||
|
||||
async def async_get_platform(self, platform_name: str) -> ModuleType:
|
||||
"""Return a platform for an integration."""
|
||||
platforms = await self.async_get_platforms([platform_name])
|
||||
# Fast path for a single platform when its already
|
||||
# cached. This is the common case.
|
||||
if platform := self._cache.get(f"{self.domain}.{platform_name}"):
|
||||
return platform # type: ignore[return-value]
|
||||
platforms = await self.async_get_platforms((platform_name,))
|
||||
return platforms[platform_name]
|
||||
|
||||
async def async_get_platforms(
|
||||
|
||||
Reference in New Issue
Block a user