mirror of
https://github.com/esphome/esphome.git
synced 2026-09-23 21:14:03 +00:00
[api] Remove virtual destructor from ProtoMessage
API protobuf messages are never deleted through base class pointers — they are always stack-allocated and passed by reference. The virtual destructor occupies 2 vtable slots (complete + deleting destructor) on 32-bit platforms using the Itanium ABI, costing 8 bytes per vtable. With 122 message classes, removing the virtual destructor saves ~976 bytes of flash. Each vtable shrinks from 24 bytes to 16 bytes.
This commit is contained in:
@@ -2473,8 +2473,7 @@ def build_base_class(
|
||||
out = f"class {base_class_name} : public {parent_class} {{\n"
|
||||
out += " public:\n"
|
||||
|
||||
# Add destructor with override
|
||||
public_content.insert(0, f"~{base_class_name}() override = default;")
|
||||
# No virtual destructor - messages are never deleted polymorphically
|
||||
|
||||
# Base classes don't implement encode/decode/calculate_size
|
||||
# Derived classes handle these with their specific field numbers
|
||||
|
||||
Reference in New Issue
Block a user