From 567672171a3f77af4a234cbc77d0bb0111a01fc4 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 30 Oct 2025 14:28:09 -0500 Subject: [PATCH] force inline --- esphome/components/select/select_call.cpp | 21 ++++++++++----------- esphome/components/select/select_call.h | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/esphome/components/select/select_call.cpp b/esphome/components/select/select_call.cpp index ae1e6b2f39..ffdadfbc26 100644 --- a/esphome/components/select/select_call.cpp +++ b/esphome/components/select/select_call.cpp @@ -46,10 +46,10 @@ SelectCall &SelectCall::with_index(size_t index) { return *this; } -optional SelectCall::calculate_target_index_(const char *name) { +optional SelectCall::calculate_target_index_() { const auto &options = this->parent_->traits.get_options(); if (options.empty()) { - ESP_LOGW(TAG, "'%s' - Select has no options", name); + ESP_LOGW(TAG, "'%s' - Select has no options", this->parent_->get_name().c_str()); return {}; } @@ -63,23 +63,23 @@ optional SelectCall::calculate_target_index_(const char *name) { if (this->operation_ == SELECT_OP_SET || this->operation_ == SELECT_OP_SET_INDEX) { if (!this->index_.has_value()) { - ESP_LOGW(TAG, "'%s' - No option set", name); + ESP_LOGW(TAG, "'%s' - No option set", this->parent_->get_name().c_str()); return {}; } auto idx = this->index_.value(); if (idx >= options.size()) { - ESP_LOGW(TAG, "'%s' - Index value %zu out of bounds", name, idx); + ESP_LOGW(TAG, "'%s' - Index value %zu out of bounds", this->parent_->get_name().c_str(), idx); return {}; } if (this->operation_ == SELECT_OP_SET) { - ESP_LOGD(TAG, "'%s' - Setting", name); + ESP_LOGD(TAG, "'%s' - Setting", this->parent_->get_name().c_str()); } return idx; } // SELECT_OP_NEXT or SELECT_OP_PREVIOUS - ESP_LOGD(TAG, "'%s' - Selecting %s, with%s cycling", name, this->operation_ == SELECT_OP_NEXT ? "next" : "previous", - this->cycle_ ? "" : "out"); + ESP_LOGD(TAG, "'%s' - Selecting %s, with%s cycling", this->parent_->get_name().c_str(), + this->operation_ == SELECT_OP_NEXT ? "next" : "previous", this->cycle_ ? "" : "out"); const auto size = options.size(); if (!this->parent_->has_state()) { @@ -105,21 +105,20 @@ optional SelectCall::calculate_target_index_(const char *name) { void SelectCall::perform() { auto *parent = this->parent_; - const auto *name = parent->get_name().c_str(); if (this->operation_ == SELECT_OP_NONE) { - ESP_LOGW(TAG, "'%s' - SelectCall performed without selecting an operation", name); + ESP_LOGW(TAG, "'%s' - SelectCall performed without selecting an operation", parent->get_name().c_str()); return; } - auto target_index = this->calculate_target_index_(name); + auto target_index = this->calculate_target_index_(); if (!target_index.has_value()) { return; } auto idx = target_index.value(); // All operations use indices, call control() by index to avoid string conversion - ESP_LOGD(TAG, "'%s' - Set selected option to: %s", name, parent->option_at(idx)); + ESP_LOGD(TAG, "'%s' - Set selected option to: %s", parent->get_name().c_str(), parent->option_at(idx)); parent->control(idx); } diff --git a/esphome/components/select/select_call.h b/esphome/components/select/select_call.h index 0b83cb143a..dc6bc85014 100644 --- a/esphome/components/select/select_call.h +++ b/esphome/components/select/select_call.h @@ -38,7 +38,7 @@ class SelectCall { SelectCall &with_index(size_t index); protected: - __attribute__((always_inline)) inline optional calculate_target_index_(const char *name); + __attribute__((always_inline)) inline optional calculate_target_index_(); Select *const parent_; optional index_;