Changed a lookup within the softlist code to use std::find_if()

This commit is contained in:
Nathan Woods 2017-04-05 20:02:55 -04:00 committed by Vas Crabb
parent ab8b83e9ed
commit 694a781215

View File

@ -75,11 +75,14 @@ software_part::software_part(software_info &info, std::string &&name, std::strin
const char *software_part::feature(const std::string &feature_name) const
{
// scan the feature list for an entry matching feature_name and return the value
for (const feature_list_item &feature : m_featurelist)
if (feature.name() == feature_name)
return feature.value().c_str();
return nullptr;
auto iter = std::find_if(
m_featurelist.begin(),
m_featurelist.end(),
[&feature_name](const feature_list_item &feature) { return feature.name() == feature_name; });
return iter != m_featurelist.end()
? iter->value().c_str()
: nullptr;
}