mirror of
https://github.com/esphome/esphome.git
synced 2026-09-30 00:10:22 +00:00
[api] Decode without a vtable
decode_field() becomes a static per message function and the generated decode() hands it to the shared loop as a function pointer, so decodable messages carry no vtable and no vptr store at every construction site. The loop loses the two vtable loads per field. The protected destructor on ProtoDecodableMessage goes with the virtuals; ProtoMessage keeps its own guard for the dump builds that still have them.
This commit is contained in:
@@ -294,11 +294,11 @@ def test_message_gets_a_single_decode_field_override() -> None:
|
||||
desc.field.add(name="count", number=2, type=UINT32)
|
||||
desc.field.add(name="level", number=3, type=FLOAT)
|
||||
header, cpp, _ = build_message_type(desc, {}, {"Mixed": SOURCE_CLIENT})
|
||||
decl = "void decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) override;"
|
||||
decl = "static void decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar);"
|
||||
assert header.count(decl) == 1
|
||||
assert (
|
||||
cpp.count(
|
||||
"void Mixed::decode_field(uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) {"
|
||||
"void Mixed::decode_field(void *self, uint32_t tag, const uint8_t *data, proto_varint_value_t scalar) {"
|
||||
)
|
||||
== 1
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user