mirror of
https://github.com/esphome/esphome.git
synced 2026-02-26 14:03:14 -07:00
Keep early guard to avoid stack buffer allocation
This commit is contained in:
@@ -276,8 +276,12 @@ void LD2450Component::dump_config() {
|
||||
}
|
||||
|
||||
void LD2450Component::loop() {
|
||||
// Read all available bytes in batches to reduce UART call overhead.
|
||||
int avail = this->available();
|
||||
if (avail <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Read all available bytes in batches to reduce UART call overhead.
|
||||
uint8_t buf[MAX_LINE_LENGTH];
|
||||
while (avail > 0) {
|
||||
size_t to_read = std::min(static_cast<size_t>(avail), sizeof(buf));
|
||||
|
||||
Reference in New Issue
Block a user