From dd44e92cb8d6ed30ce18f410ba0e1648b6df3f75 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 18 Mar 2026 12:45:01 -1000 Subject: [PATCH] [ld2412] Inline trivial gate threshold number setters Move set_gate_move_threshold_number and set_gate_still_threshold_number definitions into the header. These are single-line array assignments called 14 times each (once per gate), and inlining them eliminates function call overhead, saving ~52 bytes of flash. --- esphome/components/ld2412/ld2412.cpp | 7 ------- esphome/components/ld2412/ld2412.h | 6 ++++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/esphome/components/ld2412/ld2412.cpp b/esphome/components/ld2412/ld2412.cpp index 6ff6963e9f..38e1a59aba 100644 --- a/esphome/components/ld2412/ld2412.cpp +++ b/esphome/components/ld2412/ld2412.cpp @@ -825,13 +825,6 @@ void LD2412Component::get_gate_threshold() { this->send_command_(CMD_QUERY_STATIC_GATE_SENS, nullptr, 0); } -void LD2412Component::set_gate_still_threshold_number(uint8_t gate, number::Number *n) { - this->gate_still_threshold_numbers_[gate] = n; -} - -void LD2412Component::set_gate_move_threshold_number(uint8_t gate, number::Number *n) { - this->gate_move_threshold_numbers_[gate] = n; -} #endif void LD2412Component::set_light_out_control() { diff --git a/esphome/components/ld2412/ld2412.h b/esphome/components/ld2412/ld2412.h index 5dd5e7bcde..7fd2245978 100644 --- a/esphome/components/ld2412/ld2412.h +++ b/esphome/components/ld2412/ld2412.h @@ -85,8 +85,10 @@ class LD2412Component : public Component, public uart::UARTDevice { void set_light_out_control(); void set_basic_config(); #ifdef USE_NUMBER - void set_gate_move_threshold_number(uint8_t gate, number::Number *n); - void set_gate_still_threshold_number(uint8_t gate, number::Number *n); + void set_gate_move_threshold_number(uint8_t gate, number::Number *n) { this->gate_move_threshold_numbers_[gate] = n; } + void set_gate_still_threshold_number(uint8_t gate, number::Number *n) { + this->gate_still_threshold_numbers_[gate] = n; + } void set_gate_threshold(); void get_gate_threshold(); #endif