[api] Outline the fixed32 writers only where memcpy is a call

On the ESP8266 the inline write was already a single store, so the
outlined helper cost a call per fixed32 field: sensor state encode went
from 615 to 864 ns on a d1 mini. ESP32 builds pass -fno-builtin-memcpy,
where the shared copy is both smaller and faster (562 to 328 ns on an
atom), so the gate is now USE_ESP32.
This commit is contained in:
J. Nick Koston
2026-09-07 11:40:01 +02:00
parent adbbda4072
commit d2e4d2c46a
+5 -4
View File
@@ -287,11 +287,12 @@ class ProtoWriteBuffer {
uint8_t *pos_;
};
// Outlined on embedded targets to save flash; on the host the write is a single store.
#ifdef USE_HOST
#define PROTO_OUTLINE_FOR_SIZE inline
#else
// ESP32 builds pass -fno-builtin-memcpy, so the inline write was already a memcpy call there and
// one shared copy is both smaller and faster. Elsewhere memcpy inlines to a single store, so keep it.
#ifdef USE_ESP32
#define PROTO_OUTLINE_FOR_SIZE __attribute__((noinline))
#else
#define PROTO_OUTLINE_FOR_SIZE inline
#endif
// Varint encoding thresholds — used by both proto_encode_* free functions and ProtoSize.