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

Style. Use range based for loops and std::find_if

parent 6f155539
...@@ -44,16 +44,15 @@ Data::Data() ...@@ -44,16 +44,15 @@ Data::Data()
void Data::updateInstalledConfigData() void Data::updateInstalledConfigData()
{ {
// Clear config vectors in each device element // Clear config vectors in each device element
for (auto&& PCIDevice = PCIDevices.begin();
PCIDevice != PCIDevices.end(); ++PCIDevice) for (auto& PCIDevice : PCIDevices)
{ {
(*PCIDevice)->installedConfigs_.clear(); PCIDevice->installedConfigs_.clear();
} }
for (auto&& USBDevice = USBDevices.begin(); for (auto& USBDevice : USBDevices)
USBDevice != USBDevices.end(); ++USBDevice)
{ {
(*USBDevice)->installedConfigs_.clear(); USBDevice->installedConfigs_.clear();
} }
installedPCIConfigs.clear(); installedPCIConfigs.clear();
...@@ -83,12 +82,11 @@ void Data::fillInstalledConfigs(std::string type) ...@@ -83,12 +82,11 @@ void Data::fillInstalledConfigs(std::string type)
configPaths = getRecursiveDirectoryFileList(MHWD_PCI_DATABASE_DIR, MHWD_CONFIG_NAME); configPaths = getRecursiveDirectoryFileList(MHWD_PCI_DATABASE_DIR, MHWD_CONFIG_NAME);
} }
for (auto&& configPath = configPaths.begin(); for (const auto& configPath : configPaths)
configPath != configPaths.end(); ++configPath)
{ {
Config *config = new Config((*configPath), type); Config *config = new Config(configPath, type);
if (config->readConfigFile((*configPath))) if (config->readConfigFile(configPath))
{ {
configs->push_back(std::shared_ptr<Config>{config}); configs->push_back(std::shared_ptr<Config>{config});
} }
...@@ -346,16 +344,11 @@ std::vector<std::shared_ptr<Config>> Data::getAllLocalRequirements(std::shared_p ...@@ -346,16 +344,11 @@ std::vector<std::shared_ptr<Config>> Data::getAllLocalRequirements(std::shared_p
if ((*dependency) == config->name_) if ((*dependency) == config->name_)
{ {
// Check if already in vector // Check if already in vector
bool found = false; bool found = std::find_if(requirements.begin(), requirements.end(),
for (auto&& requirement = requirements.begin(); [&installedConfig](const std::shared_ptr<Config>& req)
requirement != requirements.end(); ++requirement)
{ {
if ((*requirement)->name_ == (*installedConfig)->name_) return req->name_ == (*installedConfig)->name_;
{ }) != requirements.end();
found = true;
break;
}
}
if (!found) if (!found)
{ {
...@@ -569,10 +562,10 @@ void Data::addConfigSorted(std::vector<std::shared_ptr<Config>>& configs, ...@@ -569,10 +562,10 @@ void Data::addConfigSorted(std::vector<std::shared_ptr<Config>>& configs,
{ {
return newConfig->name_ == config->name_; return newConfig->name_ == config->name_;
}) != configs.end(); }) != configs.end();
if (!found) if (!found)
{ {
for (auto&& config = configs.begin(); config != configs.end(); for (auto&& config = configs.begin(); config != configs.end(); ++config)
config++)
{ {
if (newConfig->priority_ > (*config)->priority_) if (newConfig->priority_ > (*config)->priority_)
{ {
......
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