mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-06-15 12:26:33 +03:00
do the toLower outside the loop
This commit is contained in:
@@ -527,8 +527,9 @@ Command::CmdFunction * Command::find_command(const uint8_t device_type, const ui
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string cmd_lower = Helpers::toLower(cmd);
|
||||||
for (auto & cf : cmdfunctions_) {
|
for (auto & cf : cmdfunctions_) {
|
||||||
if (Helpers::toLower(cmd) == Helpers::toLower(cf.cmd_) && (cf.device_type_ == device_type) && (!device_id || cf.device_id_ == device_id)
|
if (cmd_lower == Helpers::toLower(cf.cmd_) && (cf.device_type_ == device_type) && (!device_id || cf.device_id_ == device_id)
|
||||||
&& (cf.device_type_ < EMSdevice::DeviceType::BOILER || flag == CommandFlag::CMD_FLAG_DEFAULT || (flag & 0x3F) == (cf.flags_ & 0x3F))) {
|
&& (cf.device_type_ < EMSdevice::DeviceType::BOILER || flag == CommandFlag::CMD_FLAG_DEFAULT || (flag & 0x3F) == (cf.flags_ & 0x3F))) {
|
||||||
return &cf;
|
return &cf;
|
||||||
}
|
}
|
||||||
@@ -554,9 +555,10 @@ void Command::erase_command(const uint8_t device_type, const char * cmd, uint8_t
|
|||||||
if ((cmd == nullptr) || (strlen(cmd) == 0) || (cmdfunctions_.empty())) {
|
if ((cmd == nullptr) || (strlen(cmd) == 0) || (cmdfunctions_.empty())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const std::string cmd_lower = Helpers::toLower(cmd);
|
||||||
auto it = cmdfunctions_.begin();
|
auto it = cmdfunctions_.begin();
|
||||||
for (auto const & cf : cmdfunctions_) {
|
for (auto const & cf : cmdfunctions_) {
|
||||||
if (Helpers::toLower(cmd) == Helpers::toLower(cf.cmd_) && (cf.device_type_ == device_type) && ((flag & 0x3F) == (cf.flags_ & 0x3F))) {
|
if (cmd_lower == Helpers::toLower(cf.cmd_) && (cf.device_type_ == device_type) && ((flag & 0x3F) == (cf.flags_ & 0x3F))) {
|
||||||
cmdfunctions_.erase(it);
|
cmdfunctions_.erase(it);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user