From d91cad1636fb579c467e3203f5236c7d8ccb503a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 4 Dec 2025 20:49:11 -0600 Subject: [PATCH] tweak --- esphome/core/scheduler.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/esphome/core/scheduler.h b/esphome/core/scheduler.h index 6ac5370167..6a3c6b3f49 100644 --- a/esphome/core/scheduler.h +++ b/esphome/core/scheduler.h @@ -32,9 +32,15 @@ struct Time48 { return {new_millis, new_major}; } - // Compare operators - manual implementation to avoid header overhead + // Compare operators - optimized for 32-bit platforms + // Written to generate same control flow as GCC's native 64-bit comparison: + // Uses cascading < comparisons instead of != to produce tighter branch sequences constexpr bool operator<(const Time48 &other) const { - return (major != other.major) ? (major < other.major) : (millis < other.millis); + if (major < other.major) + return true; + if (other.major < major) + return false; + return millis < other.millis; } constexpr bool operator>(const Time48 &other) const { return other < *this; } constexpr bool operator<=(const Time48 &other) const { return !(other < *this); }