From 875506f2f7fd938d8f972720269ad8eeb9b9cf63 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 24 Oct 2025 17:30:04 -0700 Subject: [PATCH 1/2] cleanup --- esphome/components/sntp/time.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/esphome/components/sntp/time.py b/esphome/components/sntp/time.py index afa7f6d1fd..d27fc9991d 100644 --- a/esphome/components/sntp/time.py +++ b/esphome/components/sntp/time.py @@ -43,17 +43,12 @@ CONFIG_SCHEMA = cv.All( async def to_code(config): servers = config[CONF_SERVERS] - server_count = len(servers) # Define server count at compile time - cg.add_define("SNTP_SERVER_COUNT", server_count) + cg.add_define("SNTP_SERVER_COUNT", len(servers)) # Pass string literals to constructor - stored in flash/rodata by compiler - # On ESP8266, LWIP doesn't support PROGMEM pointers, so strings are in rodata (RAM) - # but we still avoid the ~24 byte std::string overhead per server - var = cg.new_Pvariable( - config[CONF_ID], cg.ArrayInitializer(*[cg.safe_exp(s) for s in servers]) - ) + var = cg.new_Pvariable(config[CONF_ID], servers) await cg.register_component(var, config) await time_.register_time(var, config) From b77db3604faae6c293468a4197779cc62ce96ba0 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 24 Oct 2025 17:32:38 -0700 Subject: [PATCH 2/2] cleanup --- esphome/components/sntp/sntp_component.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/sntp/sntp_component.h b/esphome/components/sntp/sntp_component.h index de40faa259..8f2e411c18 100644 --- a/esphome/components/sntp/sntp_component.h +++ b/esphome/components/sntp/sntp_component.h @@ -18,7 +18,7 @@ namespace sntp { /// \see https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html class SNTPComponent : public time::RealTimeClock { public: - SNTPComponent(std::array servers) : servers_(servers) {} + SNTPComponent(const std::array &servers) : servers_(servers) {} void setup() override; void dump_config() override;