From f00e9528da50624363ad437fc88312871bf266c7 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 4 Oct 2025 12:45:51 -0500 Subject: [PATCH] [api] Simplify message reading conditional --- esphome/components/api/api_connection.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/esphome/components/api/api_connection.cpp b/esphome/components/api/api_connection.cpp index 2d12bf5f09..89da912aea 100644 --- a/esphome/components/api/api_connection.cpp +++ b/esphome/components/api/api_connection.cpp @@ -169,11 +169,8 @@ void APIConnection::loop() { } else { this->last_traffic_ = now; // read a packet - if (buffer.data_len > 0) { - this->read_message(buffer.data_len, buffer.type, &buffer.container[buffer.data_offset]); - } else { - this->read_message(0, buffer.type, nullptr); - } + this->read_message(buffer.data_len, buffer.type, + buffer.data_len > 0 ? &buffer.container[buffer.data_offset] : nullptr); if (this->flags_.remove) return; }