replace for loop with std::transform

Seems to be a small performance boost with make test.

Total Test time (real) =   5.17 sec

vs

Total Test time (real) =   5.11 sec

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2020-11-01 20:41:25 -08:00
parent d21ca056e0
commit d762f869f2

View File

@ -2225,12 +2225,16 @@ void
Options::generate_all_groups_help(String& result) const
{
std::vector<std::string> all_groups;
all_groups.reserve(m_help.size());
for (const auto& group : m_help)
{
all_groups.push_back(group.first);
}
std::transform(
m_help.begin(),
m_help.end(),
std::back_inserter(all_groups),
[] (const std::map<std::string, HelpGroupDetails>::value_type& group)
{
return group.first;
}
);
generate_group_help(result, all_groups);
}