mirror of
https://github.com/esphome/esphome.git
synced 2026-09-14 08:38:39 +00:00
[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.
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user