From 6d2c700c438e63fc6e2f8dc0da69ceb9790fdec3 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 17 Oct 2025 13:43:05 -1000 Subject: [PATCH] relo --- esphome/analyze_memory/__init__.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/esphome/analyze_memory/__init__.py b/esphome/analyze_memory/__init__.py index c6fdb1028d..b85b1d5765 100644 --- a/esphome/analyze_memory/__init__.py +++ b/esphome/analyze_memory/__init__.py @@ -1,6 +1,7 @@ """Memory usage analyzer for ESPHome compiled binaries.""" from collections import defaultdict +from functools import cache import json import logging from pathlib import Path @@ -13,6 +14,7 @@ _LOGGER = logging.getLogger(__name__) # Get the list of actual ESPHome components by scanning the components directory +@cache def get_esphome_components(): """Get set of actual ESPHome components from the components directory.""" components = set() @@ -34,10 +36,6 @@ def get_esphome_components(): return components -# Cache the component list -ESPHOME_COMPONENTS = get_esphome_components() - - class MemorySection: """Represents a memory section with its symbols.""" @@ -285,7 +283,7 @@ class MemoryAnalyzer: if "esphome::" in demangled: # Check for special component classes that include component name in the class # For example: esphome::ESPHomeOTAComponent -> ota component - for component_name in ESPHOME_COMPONENTS: + for component_name in get_esphome_components(): # Check various naming patterns component_upper = component_name.upper() component_camel = component_name.replace("_", "").title() @@ -307,7 +305,7 @@ class MemoryAnalyzer: component_name = component_name.rstrip("_") # Check if this is an actual component in the components directory - if component_name in ESPHOME_COMPONENTS: + if component_name in get_esphome_components(): return f"[esphome]{component_name}" # Check if this is a known external component from the config if component_name in self.external_components: