[select] Refactor to index-based operations for immediate and future RAM savings (#11623)

This commit is contained in:
J. Nick Koston authored and GitHub committed 2025-11-05 11:33:01 +13:00
1 parent c7ae424613
commit 6f7e54c3f3
44 files changed
+268 -204

No files matched your search

@@ -3,10 +3,10 @@
namespace esphome::logger {
void LoggerLevelSelect::publish_state(int level) {
const auto &option = this->at(level_to_index(level));
if (!option)
auto index = level_to_index(level);
if (!this->has_index(index))
return;
Select::publish_state(option.value());
Select::publish_state(index);
}
void LoggerLevelSelect::setup() {
@@ -14,11 +14,6 @@ void LoggerLevelSelect::setup() {
this->publish_state(this->parent_->get_log_level());
}
void LoggerLevelSelect::control(const std::string &value) {
const auto index = this->index_of(value);
if (!index)
return;
this->parent_->set_log_level(index_to_level(index.value()));
}
void LoggerLevelSelect::control(size_t index) { this->parent_->set_log_level(index_to_level(index)); }
} // namespace esphome::logger