Skip to content

Commit

Permalink
Use plain for loops to enhance readability
Browse files Browse the repository at this point in the history
  • Loading branch information
ovalenti committed Jul 4, 2024
1 parent 500b25b commit f9468f1
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions collector/lib/CollectorConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,35 +173,33 @@ void CollectorConfig::InitCollectorConfig(CollectorArgs* args) {
ignored_l4proto_port_pairs_ = kIgnoredL4ProtoPortPairs;
}

std::for_each(ignored_networks.value().begin(), ignored_networks.value().end(),
[&ignored_networks = this->ignored_networks_](const std::string& str) {
if (str.empty())
return;

std::optional<IPNet> net = IPNet::parse(str);

if (net) {
CLOG(INFO) << "Ignore network : " << *net;
ignored_networks.emplace_back(std::move(*net));
} else {
CLOG(ERROR) << "Invalid network in ROX_IGNORE_NETWORKS : " << str;
}
});

std::for_each(non_aggregated_networks.value().begin(), non_aggregated_networks.value().end(),
[&non_aggregated_networks = this->non_aggregated_networks_](const std::string& str) {
if (str.empty())
return;

std::optional<IPNet> net = IPNet::parse(str);

if (net) {
CLOG(INFO) << "Detail network : " << *net;
non_aggregated_networks.emplace_back(std::move(*net));
} else {
CLOG(ERROR) << "Invalid network in ROX_NON_AGGREGATED_NETWORKS : " << str;
}
});
for (const std::string &str : ignored_networks.value()) {
if (str.empty())
continue;

std::optional<IPNet> net = IPNet::parse(str);

if (net) {
CLOG(INFO) << "Ignore network : " << *net;
ignored_networks_.emplace_back(std::move(*net));
} else {
CLOG(ERROR) << "Invalid network in ROX_IGNORE_NETWORKS : " << str;
}
}

for (const std::string &str : non_aggregated_networks.value()) {
if (str.empty())
continue;

std::optional<IPNet> net = IPNet::parse(str);

if (net) {
CLOG(INFO) << "Detail network : " << *net;
non_aggregated_networks_.emplace_back(std::move(*net));
} else {
CLOG(ERROR) << "Invalid network in ROX_NON_AGGREGATED_NETWORKS : " << str;
}
}

if (set_curl_verbose) {
curl_verbose_ = true;
Expand Down

0 comments on commit f9468f1

Please sign in to comment.