config: Don't create differently-typed copies of input in loops

This is prompted by 1f8101ef22. This
approach should still be correct while hopefully not bothering any
compilers *and* avoiding unnecessary copies or conversions until the
input actually needs to be converted to a different type (in this case
std::string_view, which is cheaper than std::string).
This commit is contained in:
Iris Morelle 2021-05-12 18:28:39 -04:00
parent 24a5ea9a8a
commit 6794f231e5

View file

@ -489,7 +489,7 @@ public:
void merge_attributes(const config &);
template<typename... T>
void remove_attributes(T... keys) {
for(const std::string key : {keys...}) {
for(const auto& key : {keys...}) {
remove_attribute(key);
}
}
@ -497,7 +497,7 @@ public:
template<typename... T>
void copy_attributes(const config& from, T... keys)
{
for(const std::string key : {keys...}) {
for(const auto& key : {keys...}) {
auto* attr = from.get(key);
if(attr) {
(*this)[key] = *attr;