mirror of
https://github.com/esphome/esphome.git
synced 2026-09-09 14:28:46 +00:00
[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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user