From 46cfc202c59782818af3061608d0c3ee626ce0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 10 Feb 2024 09:12:51 +0100 Subject: [PATCH] useStlAlgorithm --- lib/settings.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/settings.cpp b/lib/settings.cpp index 7af00d15730..b0c03b1fb7f 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -550,18 +550,16 @@ bool Settings::isPremiumEnabled(const char id[]) const void Settings::setMisraRuleTexts(const ExecuteCmdFn& executeCommand) { if (premiumArgs.find("--misra-c-20") != std::string::npos) { - for (const auto& a: addonInfos) { - if (a.name == "premiumaddon.json") { - std::string arg; - if (premiumArgs.find("--misra-c-2023") != std::string::npos) - arg = "--misra-c-2023-rule-texts"; - else - arg = "--misra-c-2012-rule-texts"; - std::string output; - executeCommand(a.executable, {arg}, "2>&1", output); - setMisraRuleTexts(output); - return; - } + const auto it = std::find_if(addonInfos.cbegin(), addonInfos.cend(), [](const AddonInfo& a) { return a.name == "premiumaddon.json"; }); + if (it != addonInfos.cend()) { + std::string arg; + if (premiumArgs.find("--misra-c-2023") != std::string::npos) + arg = "--misra-c-2023-rule-texts"; + else + arg = "--misra-c-2012-rule-texts"; + std::string output; + executeCommand(it->executable, {"--misra-c-2023-rule-texts"}, "2>&1", output); + setMisraRuleTexts(output); } } }