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