From 671e434400dc4009680418a38d4d7cd5567d08c5 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 8 Apr 2026 20:25:35 -1000 Subject: [PATCH] [core] Force-inline format_hex_char to prevent outlining The loop split in format_hex_internal doubled the call sites for format_hex_char, causing the compiler to outline it (+30 bytes new symbol). Mark it always_inline to keep it inlined. --- esphome/core/helpers.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/esphome/core/helpers.h b/esphome/core/helpers.h index c26bbe17b75..1185db390e7 100644 --- a/esphome/core/helpers.h +++ b/esphome/core/helpers.h @@ -1263,13 +1263,15 @@ constexpr uint8_t parse_hex_char(char c) { } /// Convert a nibble (0-15) to hex char with specified base ('a' for lowercase, 'A' for uppercase) -inline char format_hex_char(uint8_t v, char base) { return v >= 10 ? base + (v - 10) : '0' + v; } +__attribute__((always_inline)) inline char format_hex_char(uint8_t v, char base) { + return v >= 10 ? base + (v - 10) : '0' + v; +} /// Convert a nibble (0-15) to lowercase hex char -inline char format_hex_char(uint8_t v) { return format_hex_char(v, 'a'); } +__attribute__((always_inline)) inline char format_hex_char(uint8_t v) { return format_hex_char(v, 'a'); } /// Convert a nibble (0-15) to uppercase hex char (used for pretty printing) -inline char format_hex_pretty_char(uint8_t v) { return format_hex_char(v, 'A'); } +__attribute__((always_inline)) inline char format_hex_pretty_char(uint8_t v) { return format_hex_char(v, 'A'); } /// Write int8 value to buffer without modulo operations. /// Buffer must have at least 4 bytes free. Returns pointer past last char written.