From a1f24b38fa26c04dccb27cca8fd871cf984cda41 Mon Sep 17 00:00:00 2001 From: proddy Date: Sat, 16 May 2026 15:39:51 +0200 Subject: [PATCH] do the toLower outside the loop --- src/core/command.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/command.cpp b/src/core/command.cpp index 4fe679e2e..39cc17c1a 100644 --- a/src/core/command.cpp +++ b/src/core/command.cpp @@ -527,8 +527,9 @@ Command::CmdFunction * Command::find_command(const uint8_t device_type, const ui return nullptr; } + const std::string cmd_lower = Helpers::toLower(cmd); 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))) { 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())) { return; } - auto it = cmdfunctions_.begin(); + const std::string cmd_lower = Helpers::toLower(cmd); + auto it = cmdfunctions_.begin(); 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); return; }