mirror of
https://github.com/esphome/esphome.git
synced 2026-09-17 18:18:43 +00:00
[api] Inline capacity check in ProtoByteBuffer::resize()
Avoid calling reserve() when capacity is already sufficient. After warmup, resize() becomes just a compare + store with no function call overhead on the hot path.
This commit is contained in:
@@ -262,7 +262,8 @@ class ProtoByteBuffer {
|
||||
}
|
||||
}
|
||||
void resize(size_t n) {
|
||||
this->reserve(n);
|
||||
if (n > this->capacity_)
|
||||
this->reserve(n);
|
||||
this->size_ = n; // no zero-fill
|
||||
}
|
||||
uint8_t *data() { return this->data_.get(); }
|
||||
|
||||
Reference in New Issue
Block a user