From 47bc24a80863c185b48f7b042e187987eae39268 Mon Sep 17 00:00:00 2001 From: Ervin Hegedus Date: Mon, 11 Aug 2025 22:28:22 +0200 Subject: [PATCH] Decrease code nest level --- src/operators/pm_from_file.cc | 47 ++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/operators/pm_from_file.cc b/src/operators/pm_from_file.cc index 07c0e900..52651e95 100644 --- a/src/operators/pm_from_file.cc +++ b/src/operators/pm_from_file.cc @@ -49,32 +49,33 @@ bool PmFromFile::init(const std::string &config, std::string *error) { std::vector tokens = split(m_param, ' '); for (const auto& token : tokens) { - if (! token.empty()) { + if (token.empty()) { + continue; + } - std::unique_ptr iss; + std::unique_ptr iss; - if (token.compare(0, 8, "https://") == 0) { - Utils::HttpsClient client; - bool ret = client.download(token); - if (ret == false) { - error->assign(client.error); - return false; - } - iss = std::make_unique(client.content); - } else { - std::string err; - std::string resource = utils::find_resource(token, config, &err); - auto file = std::make_unique(resource, std::ios::in); - if (file->is_open() == false) { - error->assign("Failed to open file: '" + token + "'. " + err); - return false; - } - iss = std::move(file); + if (token.compare(0, 8, "https://") == 0) { + Utils::HttpsClient client; + bool ret = client.download(token); + if (ret == false) { + error->assign(client.error); + return false; } - for (std::string line; std::getline(*iss, line); ) { - if (isComment(line) == false) { - acmp_add_pattern(m_p, line.c_str(), NULL, NULL, line.length()); - } + iss = std::make_unique(client.content); + } else { + std::string err; + std::string resource = utils::find_resource(token, config, &err); + auto file = std::make_unique(resource, std::ios::in); + if (file->is_open() == false) { + error->assign("Failed to open file: '" + token + "'. " + err); + return false; + } + iss = std::move(file); + } + for (std::string line; std::getline(*iss, line); ) { + if (isComment(line) == false) { + acmp_add_pattern(m_p, line.c_str(), NULL, NULL, line.length()); } } }