From dc2085cc2515e51b3770a71775aedaaeac5079d9 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 11 Feb 2026 11:11:22 -0600 Subject: [PATCH] tweaks --- esphome/components/api/proto.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/esphome/components/api/proto.h b/esphome/components/api/proto.h index 6eb4135df95..4546851aecf 100644 --- a/esphome/components/api/proto.h +++ b/esphome/components/api/proto.h @@ -221,11 +221,11 @@ class ProtoWriteBuffer { this->buffer_->push_back(static_cast(value)); return; } - while (value) { - uint8_t temp = value & 0x7F; + while (value > 0x7F) { + this->buffer_->push_back(static_cast(value | 0x80)); value >>= 7; - this->buffer_->push_back(value ? (temp | 0x80) : temp); } + this->buffer_->push_back(static_cast(value)); } void encode_varint_raw_64(uint64_t value) { while (value > 0x7F) { @@ -289,7 +289,7 @@ class ProtoWriteBuffer { if (!value && !force) return; this->encode_field_raw(field_id, 0); // type 0: Varint - bool - this->write(0x01); + this->buffer_->push_back(0x01); } void encode_fixed32(uint32_t field_id, uint32_t value, bool force = false) { if (value == 0 && !force)