[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:
J. Nick Koston
2026-03-07 08:22:09 -10:00
parent 85e818dda7
commit 25a68e9339
+2 -1
View File
@@ -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(); }