From 21929eb157c50f83638f08a125ed7ef1c497a443 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 20 Mar 2026 23:07:12 -1000 Subject: [PATCH] [api] Remove noinline from encode_fixed32 Profiling showed the noinline call overhead dominated hot paths like SensorStateResponse encoding, where encode_fixed32 is called twice per message (once for key, once via encode_float for state). The function body is trivial (tag byte + 4-byte memcpy), so the function call prologue/epilogue cost exceeded the actual work. Despite 51 call sites, removing noinline shows no measurable flash size increase (555167 bytes before and after on ESP32). --- esphome/components/api/proto.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/esphome/components/api/proto.h b/esphome/components/api/proto.h index d6e993d3a5a..e7802c722b8 100644 --- a/esphome/components/api/proto.h +++ b/esphome/components/api/proto.h @@ -276,8 +276,7 @@ class ProtoWriteBuffer { this->debug_check_bounds_(1); *this->pos_++ = value ? 0x01 : 0x00; } - // noinline: 51 call sites; inlining causes net code growth vs a single out-of-line copy - __attribute__((noinline)) void encode_fixed32(uint32_t field_id, uint32_t value, bool force = false) { + void encode_fixed32(uint32_t field_id, uint32_t value, bool force = false) { if (value == 0 && !force) return;