From c3252e861f95ceefa7cf468e66dcf08c0d65cd73 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 27 Feb 2026 10:39:53 -1000 Subject: [PATCH] Don't allocate Mutex on single-threaded platforms On ESPHOME_THREAD_SINGLE (ESP8266), the lock is never used. Guarding it avoids the static local guard variable overhead (8 bytes RAM + init check on every call). Co-Authored-By: Claude Opus 4.6 --- esphome/core/time_64.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/esphome/core/time_64.cpp b/esphome/core/time_64.cpp index c967505544..d067bc11c6 100644 --- a/esphome/core/time_64.cpp +++ b/esphome/core/time_64.cpp @@ -21,7 +21,9 @@ static constexpr uint32_t HALF_MAX_UINT32 = std::numeric_limits::max() uint64_t Millis64Impl::compute(uint32_t now) { // State variables for rollover tracking - static to persist across calls +#ifndef ESPHOME_THREAD_SINGLE static Mutex lock; +#endif #ifdef ESPHOME_THREAD_MULTI_ATOMICS /* * Multi-threaded platforms with atomic support: last_millis needs atomic for lock-free updates.