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 <noreply@anthropic.com>
This commit is contained in:
J. Nick Koston
2026-02-27 10:39:53 -10:00
parent ea47af1fe3
commit c3252e861f

View File

@@ -21,7 +21,9 @@ static constexpr uint32_t HALF_MAX_UINT32 = std::numeric_limits<uint32_t>::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.