Commit d11d4500 authored by Łukasz Matysiak's avatar Łukasz Matysiak
Browse files

Use range based for loops

parent d5a9fdd0
...@@ -210,26 +210,25 @@ void Data::getAllDependenciesToInstall(std::shared_ptr<Config> config, ...@@ -210,26 +210,25 @@ void Data::getAllDependenciesToInstall(std::shared_ptr<Config> config,
std::vector<std::shared_ptr<Config>>& installedConfigs, std::vector<std::shared_ptr<Config>>& installedConfigs,
std::vector<std::shared_ptr<Config>> *dependencies) std::vector<std::shared_ptr<Config>> *dependencies)
{ {
for (auto&& configDependency = config->dependencies_.begin(); for (const auto& configDependency : config->dependencies_)
configDependency != config->dependencies_.end(); ++configDependency)
{ {
auto found = std::find_if(installedConfigs.begin(), installedConfigs.end(), auto found = std::find_if(installedConfigs.begin(), installedConfigs.end(),
[configDependency](const std::shared_ptr<Config>& config) -> bool { [configDependency](const std::shared_ptr<Config>& config) -> bool {
return (config->name_ == *configDependency); return (config->name_ == configDependency);
}) != installedConfigs.end(); }) != installedConfigs.end();
if (!found) if (!found)
{ {
found = std::find_if(dependencies->begin(), dependencies->end(), found = std::find_if(dependencies->begin(), dependencies->end(),
[configDependency](const std::shared_ptr<Config>& config) -> bool { [configDependency](const std::shared_ptr<Config>& config) -> bool {
return (config->name_ == *configDependency); return (config->name_ == configDependency);
}) != dependencies->end(); }) != dependencies->end();
if (!found) if (!found)
{ {
// Add to vector and check for further subdepends... // Add to vector and check for further subdepends...
std::shared_ptr<Config> dependconfig { std::shared_ptr<Config> dependconfig {
getDatabaseConfig((*configDependency), config->type_)}; getDatabaseConfig(configDependency, config->type_)};
if (nullptr != dependconfig) if (nullptr != dependconfig)
{ {
dependencies->emplace_back(dependconfig); dependencies->emplace_back(dependconfig);
...@@ -284,32 +283,23 @@ std::vector<std::shared_ptr<Config>> Data::getAllLocalConflicts(std::shared_ptr< ...@@ -284,32 +283,23 @@ std::vector<std::shared_ptr<Config>> Data::getAllLocalConflicts(std::shared_ptr<
dependencies.emplace_back(config); dependencies.emplace_back(config);
for (auto&& dependency = dependencies.begin(); for (const auto& dependency : dependencies)
dependency != dependencies.end(); ++dependency)
{ {
for (auto&& dependencyConflict = (*dependency)->conflicts_.begin(); for (const auto& dependencyConflict : dependency->conflicts_)
dependencyConflict != (*dependency)->conflicts_.end(); ++dependencyConflict)
{ {
for (auto&& installedConfig = installedConfigs.begin(); for (auto& installedConfig : installedConfigs)
installedConfig != installedConfigs.end(); ++installedConfig)
{ {
if ((*dependencyConflict) == (*installedConfig)->name_) if (dependencyConflict == installedConfig->name_)
{
// Check if already in vector
bool found = false;
for (auto&& conflict = conflicts.begin();
conflict != conflicts.end(); ++conflict)
{ {
if ((*conflict)->name_ == (*dependencyConflict)) bool found = std::find_if(conflicts.begin(), conflicts.end(),
[&dependencyConflict](const std::shared_ptr<Config>& conflict)
{ {
found = true; return conflict->name_ == dependencyConflict;
break; }) != conflicts.end();
}
}
if (!found) if (!found)
{ {
conflicts.emplace_back(*installedConfig); conflicts.emplace_back(installedConfig);
break; break;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment