mirror of
https://github.com/esphome/esphome.git
synced 2026-10-07 03:16:37 +00:00
[api] Inline DeferredBatch::push_item to avoid call overhead
push_item was defined out-of-line in the .cpp to avoid duplicate _M_realloc_insert instantiation, but the function call overhead on every add_item was visible in benchmarks. Move it inline since it's a one-liner wrapper around push_back.
This commit is contained in:
@@ -2072,8 +2072,6 @@ void APIConnection::on_fatal_error() {
|
|||||||
this->flags_.remove = true;
|
this->flags_.remove = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __attribute__((flatten)) APIConnection::DeferredBatch::push_item(const BatchItem &item) { items.push_back(item); }
|
|
||||||
|
|
||||||
void APIConnection::DeferredBatch::add_item(EntityBase *entity, uint8_t message_type, uint8_t estimated_size,
|
void APIConnection::DeferredBatch::add_item(EntityBase *entity, uint8_t message_type, uint8_t estimated_size,
|
||||||
uint8_t aux_data_index) {
|
uint8_t aux_data_index) {
|
||||||
// Check if we already have a message of this type for this entity
|
// Check if we already have a message of this type for this entity
|
||||||
|
|||||||
@@ -647,8 +647,7 @@ class APIConnection final : public APIServerConnectionBase {
|
|||||||
uint8_t aux_data_index = AUX_DATA_UNUSED);
|
uint8_t aux_data_index = AUX_DATA_UNUSED);
|
||||||
// Add item to the front of the batch (for high priority messages like ping)
|
// Add item to the front of the batch (for high priority messages like ping)
|
||||||
void add_item_front(EntityBase *entity, uint8_t message_type, uint8_t estimated_size);
|
void add_item_front(EntityBase *entity, uint8_t message_type, uint8_t estimated_size);
|
||||||
// Single push_back site to avoid duplicate _M_realloc_insert instantiation
|
void push_item(const BatchItem &item) { items.push_back(item); }
|
||||||
void push_item(const BatchItem &item);
|
|
||||||
|
|
||||||
// Clear all items
|
// Clear all items
|
||||||
void clear() {
|
void clear() {
|
||||||
|
|||||||
Reference in New Issue
Block a user