From c082ee616e2928d4c1b9215a2ccf19fc753691bf Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 11 Jul 2025 14:12:03 -1000 Subject: [PATCH] address feedback --- esphome/components/api/api_pb2_size.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/esphome/components/api/api_pb2_size.h b/esphome/components/api/api_pb2_size.h index 6a86038ab8..94c707c17a 100644 --- a/esphome/components/api/api_pb2_size.h +++ b/esphome/components/api/api_pb2_size.h @@ -379,7 +379,8 @@ class ProtoSize { } // Calculate and directly add to total_size - total_size += field_id_size + varint(static_cast(str.size())) + str.size(); + const uint32_t str_size = static_cast(str.size()); + total_size += field_id_size + varint(str_size) + str_size; } /** @@ -387,8 +388,8 @@ class ProtoSize { */ static inline void add_string_field_repeated(uint32_t &total_size, uint32_t field_id_size, const std::string &str) { // Always calculate size for repeated fields - // No local variable needed for simple case - total_size += field_id_size + varint(static_cast(str.size())) + str.size(); + const uint32_t str_size = static_cast(str.size()); + total_size += field_id_size + varint(str_size) + str_size; } /**