[select] Remove STL algorithm overhead to reduce flash usage (#10887)

This commit is contained in:
J. Nick Koston authored and GitHub committed 2025-09-26 12:19:06 +12:00
1 parent 875ada86b0
commit b26776fad4
2 files changed
+6 -5

No files matched your search

+5 -4
View File
@@ -34,11 +34,12 @@ size_t Select::size() const {
optional<size_t> Select::index_of(const std::string &option) const {
const auto &options = traits.get_options();
auto it = std::find(options.begin(), options.end(), option);
if (it == options.end()) {
return {};
for (size_t i = 0; i < options.size(); i++) {
if (options[i] == option) {
return i;
}
}
return std::distance(options.begin(), it);
return {};
}
optional<size_t> Select::active_index() const {
+1 -1
View File
@@ -107,7 +107,7 @@ void SelectCall::perform() {
}
}
if (std::find(options.begin(), options.end(), target_value) == options.end()) {
if (!parent->has_option(target_value)) {
ESP_LOGW(TAG, "'%s' - Option %s is not a valid option", name, target_value.c_str());
return;
}